@@ -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_RELEASE_TYPE = ' pip_version'
21
23
EXT_PIP = ' homeassistant'
22
24
BUILD_VERSION_ARG = ' HASS_RELEASE'
@@ -38,9 +40,23 @@ pipeline {
38
40
CI_WEBPATH = ' '
39
41
}
40
42
stages {
43
+ stage(" Set git config" ){
44
+ steps{
45
+ sh ''' #!/bin/bash
46
+ cat ${GIT_SIGNING_KEY} > /config/.ssh/id_sign
47
+ chmod 600 /config/.ssh/id_sign
48
+ ssh-keygen -y -f /config/.ssh/id_sign > /config/.ssh/id_sign.pub
49
+ echo "Using $(ssh-keygen -lf /config/.ssh/id_sign) to sign commits"
50
+ git config --global gpg.format ssh
51
+ git config --global user.signingkey /config/.ssh/id_sign
52
+ git config --global commit.gpgsign true
53
+ '''
54
+ }
55
+ }
41
56
// Setup all the basic environment variables needed for the build
42
57
stage(" Set ENV Variables base" ){
43
58
steps{
59
+ echo " Running on node: ${ NODE_NAME} "
44
60
sh ''' #! /bin/bash
45
61
containers=$(docker ps -aq)
46
62
if [[ -n "${containers}" ]]; then
@@ -382,9 +398,9 @@ pipeline {
382
398
echo "Updating Unraid template"
383
399
cd ${TEMPDIR}/unraid/templates/
384
400
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
385
- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
401
+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
386
402
echo "Image is on the ignore list, and already in the deprecation folder."
387
- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
403
+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
388
404
echo "Image is on the ignore list, marking Unraid template as deprecated"
389
405
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
390
406
git add -u unraid/${CONTAINER_NAME}.xml
@@ -477,10 +493,10 @@ pipeline {
477
493
}
478
494
}
479
495
/* #######################
480
- GitLab Mirroring
496
+ GitLab Mirroring and Quay.io Repo Visibility
481
497
####################### */
482
- // Ping into Gitlab to mirror this repo and have a registry endpoint
483
- stage(" GitLab Mirror" ){
498
+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
499
+ stage(" GitLab Mirror and Quay.io Visibility " ){
484
500
when {
485
501
environment name : ' EXIT_STATUS' , value : ' '
486
502
}
@@ -496,6 +512,8 @@ pipeline {
496
512
"visibility":"public"}' '''
497
513
sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
498
514
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
515
+ 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" \
516
+ -d '{"visibility":"public"}' ||: '''
499
517
}
500
518
}
501
519
/* ###############
@@ -590,7 +608,7 @@ pipeline {
590
608
--provenance=false --sbom=false \
591
609
--build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
592
610
sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
593
- retry( 5 ) {
611
+ retry_backoff( 5 , 5 ) {
594
612
sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
595
613
}
596
614
sh ''' #! /bin/bash
@@ -746,7 +764,7 @@ pipeline {
746
764
passwordVariable : ' QUAYPASS'
747
765
]
748
766
]) {
749
- retry( 5 ) {
767
+ retry_backoff( 5 , 5 ) {
750
768
sh ''' #! /bin/bash
751
769
set -e
752
770
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -764,7 +782,7 @@ pipeline {
764
782
docker push ${PUSHIMAGE}:${META_TAG}
765
783
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
766
784
if [ -n "${SEMVER}" ]; then
767
- docker push ${PUSHIMAGE}:${SEMVER}
785
+ docker push ${PUSHIMAGE}:${SEMVER}
768
786
fi
769
787
done
770
788
'''
@@ -787,7 +805,7 @@ pipeline {
787
805
passwordVariable : ' QUAYPASS'
788
806
]
789
807
]) {
790
- retry( 5 ) {
808
+ retry_backoff( 5 , 5 ) {
791
809
sh ''' #! /bin/bash
792
810
set -e
793
811
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -850,7 +868,7 @@ pipeline {
850
868
"object": "'${COMMIT_SHA}'",\
851
869
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to main",\
852
870
"type": "commit",\
853
- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
871
+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
854
872
echo " Pushing New release for Tag"
855
873
sh ''' #! /bin/bash
856
874
echo "Updating PIP version of ${EXT_PIP} to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -982,6 +1000,13 @@ EOF
982
1000
###################### */
983
1001
post {
984
1002
always {
1003
+ sh ''' #!/bin/bash
1004
+ rm -rf /config/.ssh/id_sign
1005
+ rm -rf /config/.ssh/id_sign.pub
1006
+ git config --global --unset gpg.format
1007
+ git config --global --unset user.signingkey
1008
+ git config --global --unset commit.gpgsign
1009
+ '''
985
1010
script{
986
1011
if (env. EXIT_STATUS == " ABORTED" ){
987
1012
sh ' echo "build aborted"'
@@ -1011,3 +1036,20 @@ EOF
1011
1036
}
1012
1037
}
1013
1038
}
1039
+
1040
+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1041
+ int n = 0
1042
+ while (n < max_attempts) {
1043
+ try {
1044
+ c()
1045
+ return
1046
+ } catch (err) {
1047
+ if ((n + 1 ) >= max_attempts) {
1048
+ throw err
1049
+ }
1050
+ sleep(power_base ** n)
1051
+ n++
1052
+ }
1053
+ }
1054
+ return
1055
+ }
0 commit comments