@@ -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 CONTAINER_NAME = ' sqlitebrowser'
2123 BUILD_VERSION_ARG = ' SQLITEB_VERSION'
2224 LS_USER = ' linuxserver'
@@ -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
@@ -385,9 +401,9 @@ pipeline {
385401 echo "Updating Unraid template"
386402 cd ${TEMPDIR}/unraid/templates/
387403 GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
388- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
404+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
389405 echo "Image is on the ignore list, and already in the deprecation folder."
390- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
406+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
391407 echo "Image is on the ignore list, marking Unraid template as deprecated"
392408 cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
393409 git add -u unraid/${CONTAINER_NAME}.xml
@@ -480,10 +496,10 @@ pipeline {
480496 }
481497 }
482498 /* #######################
483- GitLab Mirroring
499+ GitLab Mirroring and Quay.io Repo Visibility
484500 ####################### */
485- // Ping into Gitlab to mirror this repo and have a registry endpoint
486- stage(" GitLab Mirror" ){
501+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
502+ stage(" GitLab Mirror and Quay.io Visibility " ){
487503 when {
488504 environment name : ' EXIT_STATUS' , value : ' '
489505 }
@@ -499,6 +515,8 @@ pipeline {
499515 "visibility":"public"}' '''
500516 sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
501517 -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
518+ 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" \
519+ -d '{"visibility":"public"}' ||: '''
502520 }
503521 }
504522 /* ###############
@@ -593,7 +611,7 @@ pipeline {
593611 --provenance=false --sbom=false \
594612 --build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
595613 sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
596- retry( 5 ) {
614+ retry_backoff( 5 , 5 ) {
597615 sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
598616 }
599617 sh ''' #! /bin/bash
@@ -749,7 +767,7 @@ pipeline {
749767 passwordVariable : ' QUAYPASS'
750768 ]
751769 ]) {
752- retry( 5 ) {
770+ retry_backoff( 5 , 5 ) {
753771 sh ''' #! /bin/bash
754772 set -e
755773 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -767,7 +785,7 @@ pipeline {
767785 docker push ${PUSHIMAGE}:${META_TAG}
768786 docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
769787 if [ -n "${SEMVER}" ]; then
770- docker push ${PUSHIMAGE}:${SEMVER}
788+ docker push ${PUSHIMAGE}:${SEMVER}
771789 fi
772790 done
773791 '''
@@ -790,7 +808,7 @@ pipeline {
790808 passwordVariable : ' QUAYPASS'
791809 ]
792810 ]) {
793- retry( 5 ) {
811+ retry_backoff( 5 , 5 ) {
794812 sh ''' #! /bin/bash
795813 set -e
796814 echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -853,7 +871,7 @@ pipeline {
853871 "object": "'${COMMIT_SHA}'",\
854872 "message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
855873 "type": "commit",\
856- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
874+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
857875 echo " Pushing New release for Tag"
858876 sh ''' #! /bin/bash
859877 echo "Updating external repo packages to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -985,6 +1003,13 @@ EOF
9851003 ###################### */
9861004 post {
9871005 always {
1006+ sh ''' #!/bin/bash
1007+ rm -rf /config/.ssh/id_sign
1008+ rm -rf /config/.ssh/id_sign.pub
1009+ git config --global --unset gpg.format
1010+ git config --global --unset user.signingkey
1011+ git config --global --unset commit.gpgsign
1012+ '''
9881013 script{
9891014 if (env. EXIT_STATUS == " ABORTED" ){
9901015 sh ' echo "build aborted"'
@@ -1014,3 +1039,20 @@ EOF
10141039 }
10151040 }
10161041}
1042+
1043+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1044+ int n = 0
1045+ while (n < max_attempts) {
1046+ try {
1047+ c()
1048+ return
1049+ } catch (err) {
1050+ if ((n + 1 ) >= max_attempts) {
1051+ throw err
1052+ }
1053+ sleep(power_base ** n)
1054+ n++
1055+ }
1056+ }
1057+ return
1058+ }
0 commit comments