@@ -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 BUILD_VERSION_ARG = ' OS'
2123 LS_USER = ' linuxserver'
2224 LS_REPO = ' docker-ci'
@@ -36,9 +38,23 @@ pipeline {
3638 CI_WEBPATH = ' '
3739 }
3840 stages {
41+ stage(" Set git config" ){
42+ steps{
43+ sh ''' #!/bin/bash
44+ cat ${GIT_SIGNING_KEY} > /config/.ssh/id_sign
45+ chmod 600 /config/.ssh/id_sign
46+ ssh-keygen -y -f /config/.ssh/id_sign > /config/.ssh/id_sign.pub
47+ echo "Using $(ssh-keygen -lf /config/.ssh/id_sign) to sign commits"
48+ git config --global gpg.format ssh
49+ git config --global user.signingkey /config/.ssh/id_sign
50+ git config --global commit.gpgsign true
51+ '''
52+ }
53+ }
3954 // Setup all the basic environment variables needed for the build
4055 stage(" Set ENV Variables base" ){
4156 steps{
57+ echo " Running on node: ${ NODE_NAME} "
4258 sh ''' #! /bin/bash
4359 containers=$(docker ps -aq)
4460 if [[ -n "${containers}" ]]; then
@@ -440,10 +456,10 @@ pipeline {
440456 }
441457 }
442458 /* #######################
443- GitLab Mirroring
459+ GitLab Mirroring and Quay.io Repo Visibility
444460 ####################### */
445- // Ping into Gitlab to mirror this repo and have a registry endpoint
446- stage(" GitLab Mirror" ){
461+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
462+ stage(" GitLab Mirror and Quay.io Visibility " ){
447463 when {
448464 environment name : ' EXIT_STATUS' , value : ' '
449465 }
@@ -459,6 +475,8 @@ pipeline {
459475 "visibility":"public"}' '''
460476 sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
461477 -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
478+ 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" \
479+ -d '{"visibility":"public"}' ||: '''
462480 }
463481 }
464482 /* ###############
@@ -553,7 +571,7 @@ pipeline {
553571 --provenance=false --sbom=false \
554572 --build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
555573 sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
556- retry( 5 ) {
574+ retry_backoff( 5 , 5 ) {
557575 sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
558576 }
559577 sh ''' #! /bin/bash
@@ -709,7 +727,7 @@ pipeline {
709727 passwordVariable : ' QUAYPASS'
710728 ]
711729 ]) {
712- retry( 5 ) {
730+ retry_backoff( 5 , 5 ) {
713731 sh ''' #! /bin/bash
714732 set -e
715733 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -727,7 +745,7 @@ pipeline {
727745 docker push ${PUSHIMAGE}:${META_TAG}
728746 docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
729747 if [ -n "${SEMVER}" ]; then
730- docker push ${PUSHIMAGE}:${SEMVER}
748+ docker push ${PUSHIMAGE}:${SEMVER}
731749 fi
732750 done
733751 '''
@@ -750,7 +768,7 @@ pipeline {
750768 passwordVariable : ' QUAYPASS'
751769 ]
752770 ]) {
753- retry( 5 ) {
771+ retry_backoff( 5 , 5 ) {
754772 sh ''' #! /bin/bash
755773 set -e
756774 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -813,7 +831,7 @@ pipeline {
813831 "object": "'${COMMIT_SHA}'",\
814832 "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
815833 "type": "commit",\
816- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
834+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
817835 echo " Pushing New release for Tag"
818836 sh ''' #! /bin/bash
819837 echo "Updating base packages to ${PACKAGE_TAG}" > releasebody.json
945963 ###################### */
946964 post {
947965 always {
966+ sh ''' #!/bin/bash
967+ rm -rf /config/.ssh/id_sign
968+ rm -rf /config/.ssh/id_sign.pub
969+ git config --global --unset gpg.format
970+ git config --global --unset user.signingkey
971+ git config --global --unset commit.gpgsign
972+ '''
948973 script{
949974 if (env. EXIT_STATUS == " ABORTED" ){
950975 sh ' echo "build aborted"'
974999 }
9751000 }
9761001}
1002+
1003+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1004+ int n = 0
1005+ while (n < max_attempts) {
1006+ try {
1007+ c()
1008+ return
1009+ } catch (err) {
1010+ if ((n + 1 ) >= max_attempts) {
1011+ throw err
1012+ }
1013+ sleep(power_base ** n)
1014+ n++
1015+ }
1016+ }
1017+ return
1018+ }
0 commit comments