@@ -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 EXT_GIT_BRANCH = ' master'
2123 EXT_USER = ' bookstackapp'
2224 EXT_REPO = ' bookstack'
@@ -39,9 +41,23 @@ pipeline {
3941 CI_WEBPATH = ' '
4042 }
4143 stages {
44+ stage(" Set git config" ){
45+ steps{
46+ sh ''' #!/bin/bash
47+ cat ${GIT_SIGNING_KEY} > /config/.ssh/id_sign
48+ chmod 600 /config/.ssh/id_sign
49+ ssh-keygen -y -f /config/.ssh/id_sign > /config/.ssh/id_sign.pub
50+ echo "Using $(ssh-keygen -lf /config/.ssh/id_sign) to sign commits"
51+ git config --global gpg.format ssh
52+ git config --global user.signingkey /config/.ssh/id_sign
53+ git config --global commit.gpgsign true
54+ '''
55+ }
56+ }
4257 // Setup all the basic environment variables needed for the build
4358 stage(" Set ENV Variables base" ){
4459 steps{
60+ echo " Running on node: ${ NODE_NAME} "
4561 sh ''' #! /bin/bash
4662 containers=$(docker ps -aq)
4763 if [[ -n "${containers}" ]]; then
@@ -391,9 +407,9 @@ pipeline {
391407 echo "Updating Unraid template"
392408 cd ${TEMPDIR}/unraid/templates/
393409 GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
394- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
410+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
395411 echo "Image is on the ignore list, and already in the deprecation folder."
396- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
412+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
397413 echo "Image is on the ignore list, marking Unraid template as deprecated"
398414 cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
399415 git add -u unraid/${CONTAINER_NAME}.xml
@@ -486,10 +502,10 @@ pipeline {
486502 }
487503 }
488504 /* #######################
489- GitLab Mirroring
505+ GitLab Mirroring and Quay.io Repo Visibility
490506 ####################### */
491- // Ping into Gitlab to mirror this repo and have a registry endpoint
492- stage(" GitLab Mirror" ){
507+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
508+ stage(" GitLab Mirror and Quay.io Visibility " ){
493509 when {
494510 environment name : ' EXIT_STATUS' , value : ' '
495511 }
@@ -505,6 +521,8 @@ pipeline {
505521 "visibility":"public"}' '''
506522 sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
507523 -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
524+ 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" \
525+ -d '{"visibility":"public"}' ||: '''
508526 }
509527 }
510528 /* ###############
@@ -599,7 +617,7 @@ pipeline {
599617 --provenance=false --sbom=false \
600618 --build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
601619 sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
602- retry( 5 ) {
620+ retry_backoff( 5 , 5 ) {
603621 sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
604622 }
605623 sh ''' #! /bin/bash
@@ -755,7 +773,7 @@ pipeline {
755773 passwordVariable : ' QUAYPASS'
756774 ]
757775 ]) {
758- retry( 5 ) {
776+ retry_backoff( 5 , 5 ) {
759777 sh ''' #! /bin/bash
760778 set -e
761779 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -773,7 +791,7 @@ pipeline {
773791 docker push ${PUSHIMAGE}:${META_TAG}
774792 docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
775793 if [ -n "${SEMVER}" ]; then
776- docker push ${PUSHIMAGE}:${SEMVER}
794+ docker push ${PUSHIMAGE}:${SEMVER}
777795 fi
778796 done
779797 '''
@@ -796,7 +814,7 @@ pipeline {
796814 passwordVariable : ' QUAYPASS'
797815 ]
798816 ]) {
799- retry( 5 ) {
817+ retry_backoff( 5 , 5 ) {
800818 sh ''' #! /bin/bash
801819 set -e
802820 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -859,7 +877,7 @@ pipeline {
859877 "object": "'${COMMIT_SHA}'",\
860878 "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
861879 "type": "commit",\
862- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
880+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
863881 echo " Pushing New release for Tag"
864882 sh ''' #! /bin/bash
865883 curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\ (.*\\ ).$:\\ 1:' > releasebody.json
@@ -991,6 +1009,13 @@ EOF
9911009 ###################### */
9921010 post {
9931011 always {
1012+ sh ''' #!/bin/bash
1013+ rm -rf /config/.ssh/id_sign
1014+ rm -rf /config/.ssh/id_sign.pub
1015+ git config --global --unset gpg.format
1016+ git config --global --unset user.signingkey
1017+ git config --global --unset commit.gpgsign
1018+ '''
9941019 script{
9951020 if (env. EXIT_STATUS == " ABORTED" ){
9961021 sh ' echo "build aborted"'
@@ -1020,3 +1045,20 @@ EOF
10201045 }
10211046 }
10221047}
1048+
1049+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1050+ int n = 0
1051+ while (n < max_attempts) {
1052+ try {
1053+ c()
1054+ return
1055+ } catch (err) {
1056+ if ((n + 1 ) >= max_attempts) {
1057+ throw err
1058+ }
1059+ sleep(power_base ** n)
1060+ n++
1061+ }
1062+ }
1063+ return
1064+ }
0 commit comments