Skip to content

Commit 1449182

Browse files
Bot Updating Templated Files
1 parent e4b8aac commit 1449182

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 = 'NGINX_VERSION'
2123
LS_USER = 'linuxserver'
2224
LS_REPO = 'docker-socket-proxy'
@@ -39,9 +41,23 @@ pipeline {
3941
CI_WEBPATH=''
4042
}
4143
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+
}
4257
// Setup all the basic environment variables needed for the build
4358
stage("Set ENV Variables base"){
4459
steps{
60+
echo "Running on node: ${NODE_NAME}"
4561
sh '''#! /bin/bash
4662
containers=$(docker ps -aq)
4763
if [[ -n "${containers}" ]]; then
@@ -446,10 +462,10 @@ pipeline {
446462
}
447463
}
448464
/* #######################
449-
GitLab Mirroring
465+
GitLab Mirroring and Quay.io Repo Visibility
450466
####################### */
451-
// Ping into Gitlab to mirror this repo and have a registry endpoint
452-
stage("GitLab Mirror"){
467+
// Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
468+
stage("GitLab Mirror and Quay.io Visibility"){
453469
when {
454470
environment name: 'EXIT_STATUS', value: ''
455471
}
@@ -465,6 +481,8 @@ pipeline {
465481
"visibility":"public"}' '''
466482
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
467483
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
484+
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" \
485+
-d '{"visibility":"public"}' ||: '''
468486
}
469487
}
470488
/* ###############
@@ -559,7 +577,7 @@ pipeline {
559577
--provenance=false --sbom=false \
560578
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
561579
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
562-
retry(5) {
580+
retry_backoff(5,5) {
563581
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
564582
}
565583
sh '''#! /bin/bash
@@ -715,7 +733,7 @@ pipeline {
715733
passwordVariable: 'QUAYPASS'
716734
]
717735
]) {
718-
retry(5) {
736+
retry_backoff(5,5) {
719737
sh '''#! /bin/bash
720738
set -e
721739
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -733,7 +751,7 @@ pipeline {
733751
docker push ${PUSHIMAGE}:${META_TAG}
734752
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
735753
if [ -n "${SEMVER}" ]; then
736-
docker push ${PUSHIMAGE}:${SEMVER}
754+
docker push ${PUSHIMAGE}:${SEMVER}
737755
fi
738756
done
739757
'''
@@ -756,7 +774,7 @@ pipeline {
756774
passwordVariable: 'QUAYPASS'
757775
]
758776
]) {
759-
retry(5) {
777+
retry_backoff(5,5) {
760778
sh '''#! /bin/bash
761779
set -e
762780
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -819,7 +837,7 @@ pipeline {
819837
"object": "'${COMMIT_SHA}'",\
820838
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to main",\
821839
"type": "commit",\
822-
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
840+
"tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
823841
echo "Pushing New release for Tag"
824842
sh '''#! /bin/bash
825843
echo "Updating external repo packages to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -951,6 +969,13 @@ EOF
951969
###################### */
952970
post {
953971
always {
972+
sh '''#!/bin/bash
973+
rm -rf /config/.ssh/id_sign
974+
rm -rf /config/.ssh/id_sign.pub
975+
git config --global --unset gpg.format
976+
git config --global --unset user.signingkey
977+
git config --global --unset commit.gpgsign
978+
'''
954979
script{
955980
if (env.EXIT_STATUS == "ABORTED"){
956981
sh 'echo "build aborted"'
@@ -980,3 +1005,20 @@ EOF
9801005
}
9811006
}
9821007
}
1008+
1009+
def retry_backoff(int max_attempts, int power_base, Closure c) {
1010+
int n = 0
1011+
while (n < max_attempts) {
1012+
try {
1013+
c()
1014+
return
1015+
} catch (err) {
1016+
if ((n + 1) >= max_attempts) {
1017+
throw err
1018+
}
1019+
sleep(power_base ** n)
1020+
n++
1021+
}
1022+
}
1023+
return
1024+
}

0 commit comments

Comments
 (0)