@@ -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 = ' WORKBENCH_RELEASE'
21
23
LS_USER = ' linuxserver'
22
24
LS_REPO = ' docker-mysql-workbench'
@@ -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
@@ -381,9 +397,9 @@ pipeline {
381
397
echo "Updating Unraid template"
382
398
cd ${TEMPDIR}/unraid/templates/
383
399
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
384
- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
400
+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
385
401
echo "Image is on the ignore list, and already in the deprecation folder."
386
- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
402
+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
387
403
echo "Image is on the ignore list, marking Unraid template as deprecated"
388
404
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
389
405
git add -u unraid/${CONTAINER_NAME}.xml
@@ -476,10 +492,10 @@ pipeline {
476
492
}
477
493
}
478
494
/* #######################
479
- GitLab Mirroring
495
+ GitLab Mirroring and Quay.io Repo Visibility
480
496
####################### */
481
- // Ping into Gitlab to mirror this repo and have a registry endpoint
482
- stage(" GitLab Mirror" ){
497
+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
498
+ stage(" GitLab Mirror and Quay.io Visibility " ){
483
499
when {
484
500
environment name : ' EXIT_STATUS' , value : ' '
485
501
}
@@ -495,6 +511,8 @@ pipeline {
495
511
"visibility":"public"}' '''
496
512
sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
497
513
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
514
+ 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" \
515
+ -d '{"visibility":"public"}' ||: '''
498
516
}
499
517
}
500
518
/* ###############
@@ -589,7 +607,7 @@ pipeline {
589
607
--provenance=false --sbom=false \
590
608
--build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
591
609
sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
592
- retry( 5 ) {
610
+ retry_backoff( 5 , 5 ) {
593
611
sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
594
612
}
595
613
sh ''' #! /bin/bash
@@ -745,7 +763,7 @@ pipeline {
745
763
passwordVariable : ' QUAYPASS'
746
764
]
747
765
]) {
748
- retry( 5 ) {
766
+ retry_backoff( 5 , 5 ) {
749
767
sh ''' #! /bin/bash
750
768
set -e
751
769
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -763,7 +781,7 @@ pipeline {
763
781
docker push ${PUSHIMAGE}:${META_TAG}
764
782
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
765
783
if [ -n "${SEMVER}" ]; then
766
- docker push ${PUSHIMAGE}:${SEMVER}
784
+ docker push ${PUSHIMAGE}:${SEMVER}
767
785
fi
768
786
done
769
787
'''
@@ -786,7 +804,7 @@ pipeline {
786
804
passwordVariable : ' QUAYPASS'
787
805
]
788
806
]) {
789
- retry( 5 ) {
807
+ retry_backoff( 5 , 5 ) {
790
808
sh ''' #! /bin/bash
791
809
set -e
792
810
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -849,7 +867,7 @@ pipeline {
849
867
"object": "'${COMMIT_SHA}'",\
850
868
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
851
869
"type": "commit",\
852
- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
870
+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
853
871
echo " Pushing New release for Tag"
854
872
sh ''' #! /bin/bash
855
873
echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json
981
999
###################### */
982
1000
post {
983
1001
always {
1002
+ sh ''' #!/bin/bash
1003
+ rm -rf /config/.ssh/id_sign
1004
+ rm -rf /config/.ssh/id_sign.pub
1005
+ git config --global --unset gpg.format
1006
+ git config --global --unset user.signingkey
1007
+ git config --global --unset commit.gpgsign
1008
+ '''
984
1009
script{
985
1010
if (env. EXIT_STATUS == " ABORTED" ){
986
1011
sh ' echo "build aborted"'
@@ -1010,3 +1035,20 @@ EOF
1010
1035
}
1011
1036
}
1012
1037
}
1038
+
1039
+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1040
+ int n = 0
1041
+ while (n < max_attempts) {
1042
+ try {
1043
+ c()
1044
+ return
1045
+ } catch (err) {
1046
+ if ((n + 1 ) >= max_attempts) {
1047
+ throw err
1048
+ }
1049
+ sleep(power_base ** n)
1050
+ n++
1051
+ }
1052
+ }
1053
+ return
1054
+ }
0 commit comments