@@ -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
CONTAINER_NAME = ' sqlitebrowser'
21
23
BUILD_VERSION_ARG = ' SQLITEB_VERSION'
22
24
LS_USER = ' linuxserver'
@@ -39,9 +41,23 @@ pipeline {
39
41
CI_WEBPATH = ' '
40
42
}
41
43
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
+ }
42
57
// Setup all the basic environment variables needed for the build
43
58
stage(" Set ENV Variables base" ){
44
59
steps{
60
+ echo " Running on node: ${ NODE_NAME} "
45
61
sh ''' #! /bin/bash
46
62
containers=$(docker ps -aq)
47
63
if [[ -n "${containers}" ]]; then
@@ -385,9 +401,9 @@ pipeline {
385
401
echo "Updating Unraid template"
386
402
cd ${TEMPDIR}/unraid/templates/
387
403
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
389
405
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
391
407
echo "Image is on the ignore list, marking Unraid template as deprecated"
392
408
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
393
409
git add -u unraid/${CONTAINER_NAME}.xml
@@ -480,10 +496,10 @@ pipeline {
480
496
}
481
497
}
482
498
/* #######################
483
- GitLab Mirroring
499
+ GitLab Mirroring and Quay.io Repo Visibility
484
500
####################### */
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 " ){
487
503
when {
488
504
environment name : ' EXIT_STATUS' , value : ' '
489
505
}
@@ -499,6 +515,8 @@ pipeline {
499
515
"visibility":"public"}' '''
500
516
sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
501
517
-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"}' ||: '''
502
520
}
503
521
}
504
522
/* ###############
@@ -593,7 +611,7 @@ pipeline {
593
611
--provenance=false --sbom=false \
594
612
--build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
595
613
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 ) {
597
615
sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
598
616
}
599
617
sh ''' #! /bin/bash
@@ -749,7 +767,7 @@ pipeline {
749
767
passwordVariable : ' QUAYPASS'
750
768
]
751
769
]) {
752
- retry( 5 ) {
770
+ retry_backoff( 5 , 5 ) {
753
771
sh ''' #! /bin/bash
754
772
set -e
755
773
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -767,7 +785,7 @@ pipeline {
767
785
docker push ${PUSHIMAGE}:${META_TAG}
768
786
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
769
787
if [ -n "${SEMVER}" ]; then
770
- docker push ${PUSHIMAGE}:${SEMVER}
788
+ docker push ${PUSHIMAGE}:${SEMVER}
771
789
fi
772
790
done
773
791
'''
@@ -790,7 +808,7 @@ pipeline {
790
808
passwordVariable : ' QUAYPASS'
791
809
]
792
810
]) {
793
- retry( 5 ) {
811
+ retry_backoff( 5 , 5 ) {
794
812
sh ''' #! /bin/bash
795
813
set -e
796
814
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -853,7 +871,7 @@ pipeline {
853
871
"object": "'${COMMIT_SHA}'",\
854
872
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
855
873
"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}'"}}' '''
857
875
echo " Pushing New release for Tag"
858
876
sh ''' #! /bin/bash
859
877
echo "Updating external repo packages to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -985,6 +1003,13 @@ EOF
985
1003
###################### */
986
1004
post {
987
1005
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
+ '''
988
1013
script{
989
1014
if (env. EXIT_STATUS == " ABORTED" ){
990
1015
sh ' echo "build aborted"'
@@ -1014,3 +1039,20 @@ EOF
1014
1039
}
1015
1040
}
1016
1041
}
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