@@ -17,6 +17,8 @@ pipeline {
1717 GITLAB_TOKEN = credentials(' b6f0f1dd-6952-4cf6-95d1-9c06380283f0' )
1818 GITLAB_NAMESPACE = credentials(' gitlab-namespace-id' )
1919 DOCKERHUB_TOKEN = credentials(' docker-hub-ci-pat' )
20+ QUAYIO_API_TOKEN = credentials(' quayio-repo-api-token' )
21+ GIT_SIGNING_KEY = credentials(' 484fbca6-9a4f-455e-b9e3-97ac98785f5f' )
2022 JSON_URL = ' https://endoflife.date/api/python.json'
2123 JSON_PATH = ' .[0].latest'
2224 BUILD_VERSION_ARG = ' PYTHON_VERSION'
@@ -38,9 +40,23 @@ pipeline {
3840 CI_WEBPATH = ' '
3941 }
4042 stages {
43+ stage(" Set git config" ){
44+ steps{
45+ sh ''' #!/bin/bash
46+ cat ${GIT_SIGNING_KEY} > /config/.ssh/id_sign
47+ chmod 600 /config/.ssh/id_sign
48+ ssh-keygen -y -f /config/.ssh/id_sign > /config/.ssh/id_sign.pub
49+ echo "Using $(ssh-keygen -lf /config/.ssh/id_sign) to sign commits"
50+ git config --global gpg.format ssh
51+ git config --global user.signingkey /config/.ssh/id_sign
52+ git config --global commit.gpgsign true
53+ '''
54+ }
55+ }
4156 // Setup all the basic environment variables needed for the build
4257 stage(" Set ENV Variables base" ){
4358 steps{
59+ echo " Running on node: ${ NODE_NAME} "
4460 sh ''' #! /bin/bash
4561 containers=$(docker ps -aq)
4662 if [[ -n "${containers}" ]]; then
@@ -444,10 +460,10 @@ pipeline {
444460 }
445461 }
446462 /* #######################
447- GitLab Mirroring
463+ GitLab Mirroring and Quay.io Repo Visibility
448464 ####################### */
449- // Ping into Gitlab to mirror this repo and have a registry endpoint
450- stage(" GitLab Mirror" ){
465+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
466+ stage(" GitLab Mirror and Quay.io Visibility " ){
451467 when {
452468 environment name : ' EXIT_STATUS' , value : ' '
453469 }
@@ -463,6 +479,8 @@ pipeline {
463479 "visibility":"public"}' '''
464480 sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
465481 -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
482+ sh ''' curl -H "Content-Type: application/json" -H "Authorization: Bearer ${QUAYIO_API_TOKEN}" -X POST "https://quay.io/api/v1/repository${QUAYIMAGE/quay.io/}/changevisibility" \
483+ -d '{"visibility":"public"}' ||: '''
466484 }
467485 }
468486 /* ###############
@@ -556,7 +574,7 @@ pipeline {
556574 --provenance=false --sbom=false \
557575 --build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
558576 sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
559- retry( 5 ) {
577+ retry_backoff( 5 , 5 ) {
560578 sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
561579 }
562580 sh ''' #! /bin/bash
@@ -633,7 +651,7 @@ pipeline {
633651 passwordVariable : ' QUAYPASS'
634652 ]
635653 ]) {
636- retry( 5 ) {
654+ retry_backoff( 5 , 5 ) {
637655 sh ''' #! /bin/bash
638656 set -e
639657 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -651,7 +669,7 @@ pipeline {
651669 docker push ${PUSHIMAGE}:${META_TAG}
652670 docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
653671 if [ -n "${SEMVER}" ]; then
654- docker push ${PUSHIMAGE}:${SEMVER}
672+ docker push ${PUSHIMAGE}:${SEMVER}
655673 fi
656674 done
657675 '''
@@ -674,7 +692,7 @@ pipeline {
674692 passwordVariable : ' QUAYPASS'
675693 ]
676694 ]) {
677- retry( 5 ) {
695+ retry_backoff( 5 , 5 ) {
678696 sh ''' #! /bin/bash
679697 set -e
680698 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -737,7 +755,7 @@ pipeline {
737755 "object": "'${COMMIT_SHA}'",\
738756 "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to alpine320",\
739757 "type": "commit",\
740- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
758+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
741759 echo " Pushing New release for Tag"
742760 sh ''' #! /bin/bash
743761 echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json
869887 ###################### */
870888 post {
871889 always {
890+ sh ''' #!/bin/bash
891+ rm -rf /config/.ssh/id_sign
892+ rm -rf /config/.ssh/id_sign.pub
893+ git config --global --unset gpg.format
894+ git config --global --unset user.signingkey
895+ git config --global --unset commit.gpgsign
896+ '''
872897 script{
873898 if (env. EXIT_STATUS == " ABORTED" ){
874899 sh ' echo "build aborted"'
898923 }
899924 }
900925}
926+
927+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
928+ int n = 0
929+ while (n < max_attempts) {
930+ try {
931+ c()
932+ return
933+ } catch (err) {
934+ if ((n + 1 ) >= max_attempts) {
935+ throw err
936+ }
937+ sleep(power_base ** n)
938+ n++
939+ }
940+ }
941+ return
942+ }
0 commit comments