@@ -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
JSON_URL = ' https://plex.tv/api/downloads/5.json'
21
23
JSON_PATH = ' .computer.Linux.version'
22
24
BUILD_VERSION_ARG = ' PLEX_RELEASE'
@@ -38,9 +40,23 @@ pipeline {
38
40
CI_WEBPATH = ' /web/index.html'
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
@@ -383,9 +399,9 @@ pipeline {
383
399
echo "Updating Unraid template"
384
400
cd ${TEMPDIR}/unraid/templates/
385
401
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
386
- if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
402
+ if grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
387
403
echo "Image is on the ignore list, and already in the deprecation folder."
388
- elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
404
+ elif grep -wq "^ ${CONTAINER_NAME}$ " ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
389
405
echo "Image is on the ignore list, marking Unraid template as deprecated"
390
406
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
391
407
git add -u unraid/${CONTAINER_NAME}.xml
@@ -478,10 +494,10 @@ pipeline {
478
494
}
479
495
}
480
496
/* #######################
481
- GitLab Mirroring
497
+ GitLab Mirroring and Quay.io Repo Visibility
482
498
####################### */
483
- // Ping into Gitlab to mirror this repo and have a registry endpoint
484
- stage(" GitLab Mirror" ){
499
+ // Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
500
+ stage(" GitLab Mirror and Quay.io Visibility " ){
485
501
when {
486
502
environment name : ' EXIT_STATUS' , value : ' '
487
503
}
@@ -497,6 +513,8 @@ pipeline {
497
513
"visibility":"public"}' '''
498
514
sh ''' curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
499
515
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
516
+ 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" \
517
+ -d '{"visibility":"public"}' ||: '''
500
518
}
501
519
}
502
520
/* ###############
@@ -591,7 +609,7 @@ pipeline {
591
609
--provenance=false --sbom=false \
592
610
--build-arg ${ BUILD_VERSION_ARG} =${ EXT_RELEASE} --build-arg VERSION=\" ${ VERSION_TAG} \" --build-arg BUILD_DATE=${ GITHUB_DATE} ."
593
611
sh " docker tag ${ IMAGE} :arm64v8-${ META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
594
- retry( 5 ) {
612
+ retry_backoff( 5 , 5 ) {
595
613
sh " docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${ COMMIT_SHA} -${ BUILD_NUMBER} "
596
614
}
597
615
sh ''' #! /bin/bash
@@ -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
@@ -765,7 +783,7 @@ pipeline {
765
783
docker push ${PUSHIMAGE}:${META_TAG}
766
784
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
767
785
if [ -n "${SEMVER}" ]; then
768
- docker push ${PUSHIMAGE}:${SEMVER}
786
+ docker push ${PUSHIMAGE}:${SEMVER}
769
787
fi
770
788
done
771
789
'''
@@ -788,7 +806,7 @@ pipeline {
788
806
passwordVariable : ' QUAYPASS'
789
807
]
790
808
]) {
791
- retry( 5 ) {
809
+ retry_backoff( 5 , 5 ) {
792
810
sh ''' #! /bin/bash
793
811
set -e
794
812
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -851,7 +869,7 @@ pipeline {
851
869
"object": "'${COMMIT_SHA}'",\
852
870
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
853
871
"type": "commit",\
854
- "tagger": {"name": "LinuxServer Jenkins ","email": "jenkins @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
872
+ "tagger": {"name": "LinuxServer-CI ","email": "ci @linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
855
873
echo " Pushing New release for Tag"
856
874
sh ''' #! /bin/bash
857
875
echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json
@@ -983,6 +1001,13 @@ EOF
983
1001
###################### */
984
1002
post {
985
1003
always {
1004
+ sh ''' #!/bin/bash
1005
+ rm -rf /config/.ssh/id_sign
1006
+ rm -rf /config/.ssh/id_sign.pub
1007
+ git config --global --unset gpg.format
1008
+ git config --global --unset user.signingkey
1009
+ git config --global --unset commit.gpgsign
1010
+ '''
986
1011
script{
987
1012
if (env. EXIT_STATUS == " ABORTED" ){
988
1013
sh ' echo "build aborted"'
@@ -1012,3 +1037,20 @@ EOF
1012
1037
}
1013
1038
}
1014
1039
}
1040
+
1041
+ def retry_backoff (int max_attempts , int power_base , Closure c ) {
1042
+ int n = 0
1043
+ while (n < max_attempts) {
1044
+ try {
1045
+ c()
1046
+ return
1047
+ } catch (err) {
1048
+ if ((n + 1 ) >= max_attempts) {
1049
+ throw err
1050
+ }
1051
+ sleep(power_base ** n)
1052
+ n++
1053
+ }
1054
+ }
1055
+ return
1056
+ }
0 commit comments