Skip to content

Commit d8824b4

Browse files
Bot Updating Templated Files
1 parent dc49592 commit d8824b4

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

Jenkinsfile

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pipeline {
1717
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
1818
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
1919
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')
2022
BUILD_VERSION_ARG = 'OS'
2123
LS_USER = 'linuxserver'
2224
LS_REPO = 'docker-baseimage-debian'
@@ -36,9 +38,23 @@ pipeline {
3638
CI_WEBPATH=''
3739
}
3840
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+
}
3954
// Setup all the basic environment variables needed for the build
4055
stage("Set ENV Variables base"){
4156
steps{
57+
echo "Running on node: ${NODE_NAME}"
4258
sh '''#! /bin/bash
4359
containers=$(docker ps -aq)
4460
if [[ -n "${containers}" ]]; then
@@ -440,10 +456,10 @@ pipeline {
440456
}
441457
}
442458
/* #######################
443-
GitLab Mirroring
459+
GitLab Mirroring and Quay.io Repo Visibility
444460
####################### */
445-
// Ping into Gitlab to mirror this repo and have a registry endpoint
446-
stage("GitLab Mirror"){
461+
// Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
462+
stage("GitLab Mirror and Quay.io Visibility"){
447463
when {
448464
environment name: 'EXIT_STATUS', value: ''
449465
}
@@ -459,6 +475,8 @@ pipeline {
459475
"visibility":"public"}' '''
460476
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
461477
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
478+
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" \
479+
-d '{"visibility":"public"}' ||: '''
462480
}
463481
}
464482
/* ###############
@@ -550,7 +568,7 @@ pipeline {
550568
--provenance=false --sbom=false \
551569
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
552570
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
553-
retry(5) {
571+
retry_backoff(5,5) {
554572
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
555573
}
556574
sh '''#! /bin/bash
@@ -706,7 +724,7 @@ pipeline {
706724
passwordVariable: 'QUAYPASS'
707725
]
708726
]) {
709-
retry(5) {
727+
retry_backoff(5,5) {
710728
sh '''#! /bin/bash
711729
set -e
712730
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -724,7 +742,7 @@ pipeline {
724742
docker push ${PUSHIMAGE}:${META_TAG}
725743
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
726744
if [ -n "${SEMVER}" ]; then
727-
docker push ${PUSHIMAGE}:${SEMVER}
745+
docker push ${PUSHIMAGE}:${SEMVER}
728746
fi
729747
done
730748
'''
@@ -747,7 +765,7 @@ pipeline {
747765
passwordVariable: 'QUAYPASS'
748766
]
749767
]) {
750-
retry(5) {
768+
retry_backoff(5,5) {
751769
sh '''#! /bin/bash
752770
set -e
753771
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -810,7 +828,7 @@ pipeline {
810828
"object": "'${COMMIT_SHA}'",\
811829
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
812830
"type": "commit",\
813-
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
831+
"tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
814832
echo "Pushing New release for Tag"
815833
sh '''#! /bin/bash
816834
echo "Updating base packages to ${PACKAGE_TAG}" > releasebody.json
@@ -942,6 +960,13 @@ EOF
942960
###################### */
943961
post {
944962
always {
963+
sh '''#!/bin/bash
964+
rm -rf /config/.ssh/id_sign
965+
rm -rf /config/.ssh/id_sign.pub
966+
git config --global --unset gpg.format
967+
git config --global --unset user.signingkey
968+
git config --global --unset commit.gpgsign
969+
'''
945970
script{
946971
if (env.EXIT_STATUS == "ABORTED"){
947972
sh 'echo "build aborted"'
@@ -971,3 +996,20 @@ EOF
971996
}
972997
}
973998
}
999+
1000+
def retry_backoff(int max_attempts, int power_base, Closure c) {
1001+
int n = 0
1002+
while (n < max_attempts) {
1003+
try {
1004+
c()
1005+
return
1006+
} catch (err) {
1007+
if ((n + 1) >= max_attempts) {
1008+
throw err
1009+
}
1010+
sleep(power_base ** n)
1011+
n++
1012+
}
1013+
}
1014+
return
1015+
}

0 commit comments

Comments
 (0)