@@ -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
EXT_GIT_BRANCH = ' master'
21
23
EXT_USER = ' bookstackapp'
22
24
EXT_REPO = ' bookstack'
@@ -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
@@ -391,9 +407,9 @@ pipeline {
391
407
echo "Updating Unraid template"
392
408
cd ${TEMPDIR}/unraid/templates/
393
409
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
394
- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
410
+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
395
411
echo "Image is on the ignore list, and already in the deprecation folder."
396
- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
412
+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
397
413
echo "Image is on the ignore list, marking Unraid template as deprecated"
398
414
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
399
415
git add -u unraid/${CONTAINER_NAME}.xml
@@ -486,10 +502,10 @@ pipeline {
486
502
}
487
503
}
488
504
/* #######################
489
- GitLab Mirroring
505
+ GitLab Mirroring and Quay.io Repo Visibility
490
506
####################### */
491
- // Ping into Gitlab to mirror this repo and have a registry endpoint
492
- stage(" GitLab Mirror" ){
507
+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
508
+ stage(" GitLab Mirror and Quay.io Visibility " ){
493
509
when {
494
510
environment name : ' EXIT_STATUS' , value : ' '
495
511
}
@@ -505,6 +521,8 @@ pipeline {
505
521
"visibility":"public"}' '''
506
522
sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
507
523
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
524
+ 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" \
525
+ -d '{"visibility":"public"}' ||: '''
508
526
}
509
527
}
510
528
/* ###############
@@ -599,7 +617,7 @@ pipeline {
599
617
--provenance=false --sbom=false \
600
618
--build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
601
619
sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
602
- retry( 5 ) {
620
+ retry_backoff( 5 , 5 ) {
603
621
sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
604
622
}
605
623
sh ''' #! /bin/bash
@@ -755,7 +773,7 @@ pipeline {
755
773
passwordVariable : ' QUAYPASS'
756
774
]
757
775
]) {
758
- retry( 5 ) {
776
+ retry_backoff( 5 , 5 ) {
759
777
sh ''' #! /bin/bash
760
778
set -e
761
779
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -773,7 +791,7 @@ pipeline {
773
791
docker push ${PUSHIMAGE}:${META_TAG}
774
792
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
775
793
if [ -n "${SEMVER}" ]; then
776
- docker push ${PUSHIMAGE}:${SEMVER}
794
+ docker push ${PUSHIMAGE}:${SEMVER}
777
795
fi
778
796
done
779
797
'''
@@ -796,7 +814,7 @@ pipeline {
796
814
passwordVariable : ' QUAYPASS'
797
815
]
798
816
]) {
799
- retry( 5 ) {
817
+ retry_backoff( 5 , 5 ) {
800
818
sh ''' #! /bin/bash
801
819
set -e
802
820
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -859,7 +877,7 @@ pipeline {
859
877
"object": "'${COMMIT_SHA}'",\
860
878
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
861
879
"type": "commit",\
862
- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
880
+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
863
881
echo " Pushing New release for Tag"
864
882
sh ''' #! /bin/bash
865
883
curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\ (.*\\ ).$:\\ 1:' > releasebody.json
@@ -991,6 +1009,13 @@ EOF
991
1009
###################### */
992
1010
post {
993
1011
always {
1012
+ sh ''' #!/bin/bash
1013
+ rm -rf /config/.ssh/id_sign
1014
+ rm -rf /config/.ssh/id_sign.pub
1015
+ git config --global --unset gpg.format
1016
+ git config --global --unset user.signingkey
1017
+ git config --global --unset commit.gpgsign
1018
+ '''
994
1019
script{
995
1020
if (env. EXIT_STATUS == " ABORTED" ){
996
1021
sh ' echo "build aborted"'
@@ -1020,3 +1045,20 @@ EOF
1020
1045
}
1021
1046
}
1022
1047
}
1048
+
1049
+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1050
+ int n = 0
1051
+ while (n < max_attempts) {
1052
+ try {
1053
+ c()
1054
+ return
1055
+ } catch (err) {
1056
+ if ((n + 1 ) >= max_attempts) {
1057
+ throw err
1058
+ }
1059
+ sleep(power_base ** n)
1060
+ n++
1061
+ }
1062
+ }
1063
+ return
1064
+ }
0 commit comments