Skip to content

Commit 9871f37

Browse files
Bot Updating Templated Files
1 parent 0d54c1a commit 9871f37

File tree

1 file changed

+52
-10
lines changed

1 file changed

+52
-10
lines changed

Jenkinsfile

Lines changed: 52 additions & 10 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 = 'WORKBENCH_RELEASE'
2123
LS_USER = 'linuxserver'
2224
LS_REPO = 'docker-mysql-workbench'
@@ -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
@@ -381,9 +397,9 @@ pipeline {
381397
echo "Updating Unraid template"
382398
cd ${TEMPDIR}/unraid/templates/
383399
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
385401
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
387403
echo "Image is on the ignore list, marking Unraid template as deprecated"
388404
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
389405
git add -u unraid/${CONTAINER_NAME}.xml
@@ -476,10 +492,10 @@ pipeline {
476492
}
477493
}
478494
/* #######################
479-
GitLab Mirroring
495+
GitLab Mirroring and Quay.io Repo Visibility
480496
####################### */
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"){
483499
when {
484500
environment name: 'EXIT_STATUS', value: ''
485501
}
@@ -495,6 +511,8 @@ pipeline {
495511
"visibility":"public"}' '''
496512
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
497513
-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"}' ||: '''
498516
}
499517
}
500518
/* ###############
@@ -589,7 +607,7 @@ pipeline {
589607
--provenance=false --sbom=false \
590608
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
591609
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) {
593611
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
594612
}
595613
sh '''#! /bin/bash
@@ -745,7 +763,7 @@ pipeline {
745763
passwordVariable: 'QUAYPASS'
746764
]
747765
]) {
748-
retry(5) {
766+
retry_backoff(5,5) {
749767
sh '''#! /bin/bash
750768
set -e
751769
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -763,7 +781,7 @@ pipeline {
763781
docker push ${PUSHIMAGE}:${META_TAG}
764782
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
765783
if [ -n "${SEMVER}" ]; then
766-
docker push ${PUSHIMAGE}:${SEMVER}
784+
docker push ${PUSHIMAGE}:${SEMVER}
767785
fi
768786
done
769787
'''
@@ -786,7 +804,7 @@ pipeline {
786804
passwordVariable: 'QUAYPASS'
787805
]
788806
]) {
789-
retry(5) {
807+
retry_backoff(5,5) {
790808
sh '''#! /bin/bash
791809
set -e
792810
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -849,7 +867,7 @@ pipeline {
849867
"object": "'${COMMIT_SHA}'",\
850868
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
851869
"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}'"}}' '''
853871
echo "Pushing New release for Tag"
854872
sh '''#! /bin/bash
855873
echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -981,6 +999,13 @@ EOF
981999
###################### */
9821000
post {
9831001
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+
'''
9841009
script{
9851010
if (env.EXIT_STATUS == "ABORTED"){
9861011
sh 'echo "build aborted"'
@@ -1010,3 +1035,20 @@ EOF
10101035
}
10111036
}
10121037
}
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

Comments
 (0)