@@ -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_USER = ' Ombi-app'
2123 EXT_REPO = ' Ombi'
2224 CONTAINER_NAME = ' ombi'
@@ -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
@@ -390,9 +406,9 @@ pipeline {
390406 echo "Updating Unraid template"
391407 cd ${TEMPDIR}/unraid/templates/
392408 GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
393- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
409+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
394410 echo "Image is on the ignore list, and already in the deprecation folder."
395- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
411+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
396412 echo "Image is on the ignore list, marking Unraid template as deprecated"
397413 cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
398414 git add -u unraid/${CONTAINER_NAME}.xml
@@ -485,10 +501,10 @@ pipeline {
485501 }
486502 }
487503 /* #######################
488- GitLab Mirroring
504+ GitLab Mirroring and Quay.io Repo Visibility
489505 ####################### */
490- // Ping into Gitlab to mirror this repo and have a registry endpoint
491- stage(" GitLab Mirror" ){
506+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
507+ stage(" GitLab Mirror and Quay.io Visibility " ){
492508 when {
493509 environment name : ' EXIT_STATUS' , value : ' '
494510 }
@@ -504,6 +520,8 @@ pipeline {
504520 "visibility":"public"}' '''
505521 sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
506522 -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
523+ 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" \
524+ -d '{"visibility":"public"}' ||: '''
507525 }
508526 }
509527 /* ###############
@@ -598,7 +616,7 @@ pipeline {
598616 --provenance=false --sbom=false \
599617 --build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
600618 sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
601- retry( 5 ) {
619+ retry_backoff( 5 , 5 ) {
602620 sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
603621 }
604622 sh ''' #! /bin/bash
@@ -754,7 +772,7 @@ pipeline {
754772 passwordVariable : ' QUAYPASS'
755773 ]
756774 ]) {
757- retry( 5 ) {
775+ retry_backoff( 5 , 5 ) {
758776 sh ''' #! /bin/bash
759777 set -e
760778 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -772,7 +790,7 @@ pipeline {
772790 docker push ${PUSHIMAGE}:${META_TAG}
773791 docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
774792 if [ -n "${SEMVER}" ]; then
775- docker push ${PUSHIMAGE}:${SEMVER}
793+ docker push ${PUSHIMAGE}:${SEMVER}
776794 fi
777795 done
778796 '''
@@ -795,7 +813,7 @@ pipeline {
795813 passwordVariable : ' QUAYPASS'
796814 ]
797815 ]) {
798- retry( 5 ) {
816+ retry_backoff( 5 , 5 ) {
799817 sh ''' #! /bin/bash
800818 set -e
801819 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -858,7 +876,7 @@ pipeline {
858876 "object": "'${COMMIT_SHA}'",\
859877 "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to development",\
860878 "type": "commit",\
861- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
879+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
862880 echo " Pushing New release for Tag"
863881 sh ''' #! /bin/bash
864882 curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases | jq '.[0] |.body' | sed 's:^.\\ (.*\\ ).$:\\ 1:' > releasebody.json
@@ -990,6 +1008,13 @@ EOF
9901008 ###################### */
9911009 post {
9921010 always {
1011+ sh ''' #!/bin/bash
1012+ rm -rf /config/.ssh/id_sign
1013+ rm -rf /config/.ssh/id_sign.pub
1014+ git config --global --unset gpg.format
1015+ git config --global --unset user.signingkey
1016+ git config --global --unset commit.gpgsign
1017+ '''
9931018 script{
9941019 if (env. EXIT_STATUS == " ABORTED" ){
9951020 sh ' echo "build aborted"'
@@ -1019,3 +1044,20 @@ EOF
10191044 }
10201045 }
10211046}
1047+
1048+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1049+ int n = 0
1050+ while (n < max_attempts) {
1051+ try {
1052+ c()
1053+ return
1054+ } catch (err) {
1055+ if ((n + 1 ) >= max_attempts) {
1056+ throw err
1057+ }
1058+ sleep(power_base ** n)
1059+ n++
1060+ }
1061+ }
1062+ return
1063+ }
0 commit comments