@@ -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 = ' phpmyadmin'
2224 EXT_REPO = ' phpmyadmin'
@@ -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
@@ -384,9 +400,9 @@ pipeline {
384400 echo "Updating Unraid template"
385401 cd ${TEMPDIR}/unraid/templates/
386402 GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
387- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
403+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
388404 echo "Image is on the ignore list, and already in the deprecation folder."
389- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
405+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
390406 echo "Image is on the ignore list, marking Unraid template as deprecated"
391407 cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
392408 git add -u unraid/${CONTAINER_NAME}.xml
@@ -479,10 +495,10 @@ pipeline {
479495 }
480496 }
481497 /* #######################
482- GitLab Mirroring
498+ GitLab Mirroring and Quay.io Repo Visibility
483499 ####################### */
484- // Ping into Gitlab to mirror this repo and have a registry endpoint
485- stage(" GitLab Mirror" ){
500+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
501+ stage(" GitLab Mirror and Quay.io Visibility " ){
486502 when {
487503 environment name : ' EXIT_STATUS' , value : ' '
488504 }
@@ -498,6 +514,8 @@ pipeline {
498514 "visibility":"public"}' '''
499515 sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
500516 -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
517+ 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" \
518+ -d '{"visibility":"public"}' ||: '''
501519 }
502520 }
503521 /* ###############
@@ -592,7 +610,7 @@ pipeline {
592610 --provenance=false --sbom=false \
593611 --build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
594612 sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
595- retry( 5 ) {
613+ retry_backoff( 5 , 5 ) {
596614 sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
597615 }
598616 sh ''' #! /bin/bash
@@ -748,7 +766,7 @@ pipeline {
748766 passwordVariable : ' QUAYPASS'
749767 ]
750768 ]) {
751- retry( 5 ) {
769+ retry_backoff( 5 , 5 ) {
752770 sh ''' #! /bin/bash
753771 set -e
754772 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -766,7 +784,7 @@ pipeline {
766784 docker push ${PUSHIMAGE}:${META_TAG}
767785 docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
768786 if [ -n "${SEMVER}" ]; then
769- docker push ${PUSHIMAGE}:${SEMVER}
787+ docker push ${PUSHIMAGE}:${SEMVER}
770788 fi
771789 done
772790 '''
@@ -789,7 +807,7 @@ pipeline {
789807 passwordVariable : ' QUAYPASS'
790808 ]
791809 ]) {
792- retry( 5 ) {
810+ retry_backoff( 5 , 5 ) {
793811 sh ''' #! /bin/bash
794812 set -e
795813 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -852,7 +870,7 @@ pipeline {
852870 "object": "'${COMMIT_SHA}'",\
853871 "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to main",\
854872 "type": "commit",\
855- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
873+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
856874 echo " Pushing New release for Tag"
857875 sh ''' #! /bin/bash
858876 echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -984,6 +1002,13 @@ EOF
9841002 ###################### */
9851003 post {
9861004 always {
1005+ sh ''' #!/bin/bash
1006+ rm -rf /config/.ssh/id_sign
1007+ rm -rf /config/.ssh/id_sign.pub
1008+ git config --global --unset gpg.format
1009+ git config --global --unset user.signingkey
1010+ git config --global --unset commit.gpgsign
1011+ '''
9871012 script{
9881013 if (env. EXIT_STATUS == " ABORTED" ){
9891014 sh ' echo "build aborted"'
@@ -1013,3 +1038,20 @@ EOF
10131038 }
10141039 }
10151040}
1041+
1042+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1043+ int n = 0
1044+ while (n < max_attempts) {
1045+ try {
1046+ c()
1047+ return
1048+ } catch (err) {
1049+ if ((n + 1 ) >= max_attempts) {
1050+ throw err
1051+ }
1052+ sleep(power_base ** n)
1053+ n++
1054+ }
1055+ }
1056+ return
1057+ }
0 commit comments