@@ -17,6 +17,8 @@ pipeline {
17
17
GITLAB_TOKEN = credentials(' b6f0f1dd-6952-4cf6-95d1-9c06380283f0' )
18
18
GITLAB_NAMESPACE = credentials(' gitlab-namespace-id' )
19
19
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' )
20
22
BUILD_VERSION_ARG = ' OS'
21
23
LS_USER = ' linuxserver'
22
24
LS_REPO = ' docker-baseimage-debian'
@@ -36,9 +38,23 @@ pipeline {
36
38
CI_WEBPATH = ' '
37
39
}
38
40
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
+ }
39
54
// Setup all the basic environment variables needed for the build
40
55
stage(" Set ENV Variables base" ){
41
56
steps{
57
+ echo " Running on node: ${ NODE_NAME} "
42
58
sh ''' #! /bin/bash
43
59
containers=$(docker ps -aq)
44
60
if [[ -n "${containers}" ]]; then
@@ -440,10 +456,10 @@ pipeline {
440
456
}
441
457
}
442
458
/* #######################
443
- GitLab Mirroring
459
+ GitLab Mirroring and Quay.io Repo Visibility
444
460
####################### */
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 " ){
447
463
when {
448
464
environment name : ' EXIT_STATUS' , value : ' '
449
465
}
@@ -459,6 +475,8 @@ pipeline {
459
475
"visibility":"public"}' '''
460
476
sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
461
477
-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"}' ||: '''
462
480
}
463
481
}
464
482
/* ###############
@@ -550,7 +568,7 @@ pipeline {
550
568
--provenance=false --sbom=false \
551
569
--build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
552
570
sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
553
- retry( 5 ) {
571
+ retry_backoff( 5 , 5 ) {
554
572
sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
555
573
}
556
574
sh ''' #! /bin/bash
@@ -706,7 +724,7 @@ pipeline {
706
724
passwordVariable : ' QUAYPASS'
707
725
]
708
726
]) {
709
- retry( 5 ) {
727
+ retry_backoff( 5 , 5 ) {
710
728
sh ''' #! /bin/bash
711
729
set -e
712
730
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -724,7 +742,7 @@ pipeline {
724
742
docker push ${PUSHIMAGE}:${META_TAG}
725
743
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
726
744
if [ -n "${SEMVER}" ]; then
727
- docker push ${PUSHIMAGE}:${SEMVER}
745
+ docker push ${PUSHIMAGE}:${SEMVER}
728
746
fi
729
747
done
730
748
'''
@@ -747,7 +765,7 @@ pipeline {
747
765
passwordVariable : ' QUAYPASS'
748
766
]
749
767
]) {
750
- retry( 5 ) {
768
+ retry_backoff( 5 , 5 ) {
751
769
sh ''' #! /bin/bash
752
770
set -e
753
771
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -810,7 +828,7 @@ pipeline {
810
828
"object": "'${COMMIT_SHA}'",\
811
829
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
812
830
"type": "commit",\
813
- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
831
+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
814
832
echo " Pushing New release for Tag"
815
833
sh ''' #! /bin/bash
816
834
echo "Updating base packages to ${PACKAGE_TAG}" > releasebody.json
942
960
###################### */
943
961
post {
944
962
always {
963
+ sh ''' #!/bin/bash
964
+ rm -rf /config/.ssh/id_sign
965
+ rm -rf /config/.ssh/id_sign.pub
966
+ git config --global --unset gpg.format
967
+ git config --global --unset user.signingkey
968
+ git config --global --unset commit.gpgsign
969
+ '''
945
970
script{
946
971
if (env. EXIT_STATUS == " ABORTED" ){
947
972
sh ' echo "build aborted"'
971
996
}
972
997
}
973
998
}
999
+
1000
+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1001
+ int n = 0
1002
+ while (n < max_attempts) {
1003
+ try {
1004
+ c()
1005
+ return
1006
+ } catch (err) {
1007
+ if ((n + 1 ) >= max_attempts) {
1008
+ throw err
1009
+ }
1010
+ sleep(power_base ** n)
1011
+ n++
1012
+ }
1013
+ }
1014
+ return
1015
+ }
0 commit comments