Skip to content

Commit 25135d4

Browse files
Bot Updating Templated Files
1 parent c59b416 commit 25135d4

1 file changed

Lines changed: 52 additions & 10 deletions

File tree

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 = 'DUCKDNS_VERSION'
2123
LS_USER = 'linuxserver'
2224
LS_REPO = 'docker-duckdns'
@@ -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
@@ -379,9 +395,9 @@ pipeline {
379395
echo "Updating Unraid template"
380396
cd ${TEMPDIR}/unraid/templates/
381397
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
382-
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
398+
if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
383399
echo "Image is on the ignore list, and already in the deprecation folder."
384-
elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
400+
elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
385401
echo "Image is on the ignore list, marking Unraid template as deprecated"
386402
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
387403
git add -u unraid/${CONTAINER_NAME}.xml
@@ -474,10 +490,10 @@ pipeline {
474490
}
475491
}
476492
/* #######################
477-
GitLab Mirroring
493+
GitLab Mirroring and Quay.io Repo Visibility
478494
####################### */
479-
// Ping into Gitlab to mirror this repo and have a registry endpoint
480-
stage("GitLab Mirror"){
495+
// Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
496+
stage("GitLab Mirror and Quay.io Visibility"){
481497
when {
482498
environment name: 'EXIT_STATUS', value: ''
483499
}
@@ -493,6 +509,8 @@ pipeline {
493509
"visibility":"public"}' '''
494510
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
495511
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
512+
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" \
513+
-d '{"visibility":"public"}' ||: '''
496514
}
497515
}
498516
/* ###############
@@ -587,7 +605,7 @@ pipeline {
587605
--provenance=false --sbom=false \
588606
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
589607
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
590-
retry(5) {
608+
retry_backoff(5,5) {
591609
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
592610
}
593611
sh '''#! /bin/bash
@@ -743,7 +761,7 @@ pipeline {
743761
passwordVariable: 'QUAYPASS'
744762
]
745763
]) {
746-
retry(5) {
764+
retry_backoff(5,5) {
747765
sh '''#! /bin/bash
748766
set -e
749767
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -761,7 +779,7 @@ pipeline {
761779
docker push ${PUSHIMAGE}:${META_TAG}
762780
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
763781
if [ -n "${SEMVER}" ]; then
764-
docker push ${PUSHIMAGE}:${SEMVER}
782+
docker push ${PUSHIMAGE}:${SEMVER}
765783
fi
766784
done
767785
'''
@@ -784,7 +802,7 @@ pipeline {
784802
passwordVariable: 'QUAYPASS'
785803
]
786804
]) {
787-
retry(5) {
805+
retry_backoff(5,5) {
788806
sh '''#! /bin/bash
789807
set -e
790808
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -847,7 +865,7 @@ pipeline {
847865
"object": "'${COMMIT_SHA}'",\
848866
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
849867
"type": "commit",\
850-
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
868+
"tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
851869
echo "Pushing New release for Tag"
852870
sh '''#! /bin/bash
853871
echo "Updating base packages to ${PACKAGE_TAG}" > releasebody.json
@@ -979,6 +997,13 @@ EOF
979997
###################### */
980998
post {
981999
always {
1000+
sh '''#!/bin/bash
1001+
rm -rf /config/.ssh/id_sign
1002+
rm -rf /config/.ssh/id_sign.pub
1003+
git config --global --unset gpg.format
1004+
git config --global --unset user.signingkey
1005+
git config --global --unset commit.gpgsign
1006+
'''
9821007
script{
9831008
if (env.EXIT_STATUS == "ABORTED"){
9841009
sh 'echo "build aborted"'
@@ -1008,3 +1033,20 @@ EOF
10081033
}
10091034
}
10101035
}
1036+
1037+
def retry_backoff(int max_attempts, int power_base, Closure c) {
1038+
int n = 0
1039+
while (n < max_attempts) {
1040+
try {
1041+
c()
1042+
return
1043+
} catch (err) {
1044+
if ((n + 1) >= max_attempts) {
1045+
throw err
1046+
}
1047+
sleep(power_base ** n)
1048+
n++
1049+
}
1050+
}
1051+
return
1052+
}

0 commit comments

Comments
 (0)