Skip to content

Commit 93509d1

Browse files
Bot Updating Templated Files
1 parent 2a2f857 commit 93509d1

File tree

1 file changed

+52
-10
lines changed

1 file changed

+52
-10
lines changed

Jenkinsfile

+52-10
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
EXT_RELEASE_TYPE = 'pip_version'
2123
EXT_PIP = 'homeassistant'
2224
BUILD_VERSION_ARG = 'HASS_RELEASE'
@@ -38,9 +40,23 @@ pipeline {
3840
CI_WEBPATH = ''
3941
}
4042
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+
}
4156
// Setup all the basic environment variables needed for the build
4257
stage("Set ENV Variables base"){
4358
steps{
59+
echo "Running on node: ${NODE_NAME}"
4460
sh '''#! /bin/bash
4561
containers=$(docker ps -aq)
4662
if [[ -n "${containers}" ]]; then
@@ -382,9 +398,9 @@ pipeline {
382398
echo "Updating Unraid template"
383399
cd ${TEMPDIR}/unraid/templates/
384400
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
385-
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
401+
if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
386402
echo "Image is on the ignore list, and already in the deprecation folder."
387-
elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
403+
elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
388404
echo "Image is on the ignore list, marking Unraid template as deprecated"
389405
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
390406
git add -u unraid/${CONTAINER_NAME}.xml
@@ -477,10 +493,10 @@ pipeline {
477493
}
478494
}
479495
/* #######################
480-
GitLab Mirroring
496+
GitLab Mirroring and Quay.io Repo Visibility
481497
####################### */
482-
// Ping into Gitlab to mirror this repo and have a registry endpoint
483-
stage("GitLab Mirror"){
498+
// Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
499+
stage("GitLab Mirror and Quay.io Visibility"){
484500
when {
485501
environment name: 'EXIT_STATUS', value: ''
486502
}
@@ -496,6 +512,8 @@ pipeline {
496512
"visibility":"public"}' '''
497513
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
498514
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
515+
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" \
516+
-d '{"visibility":"public"}' ||: '''
499517
}
500518
}
501519
/* ###############
@@ -590,7 +608,7 @@ pipeline {
590608
--provenance=false --sbom=false \
591609
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
592610
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
593-
retry(5) {
611+
retry_backoff(5,5) {
594612
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
595613
}
596614
sh '''#! /bin/bash
@@ -746,7 +764,7 @@ pipeline {
746764
passwordVariable: 'QUAYPASS'
747765
]
748766
]) {
749-
retry(5) {
767+
retry_backoff(5,5) {
750768
sh '''#! /bin/bash
751769
set -e
752770
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -764,7 +782,7 @@ pipeline {
764782
docker push ${PUSHIMAGE}:${META_TAG}
765783
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
766784
if [ -n "${SEMVER}" ]; then
767-
docker push ${PUSHIMAGE}:${SEMVER}
785+
docker push ${PUSHIMAGE}:${SEMVER}
768786
fi
769787
done
770788
'''
@@ -787,7 +805,7 @@ pipeline {
787805
passwordVariable: 'QUAYPASS'
788806
]
789807
]) {
790-
retry(5) {
808+
retry_backoff(5,5) {
791809
sh '''#! /bin/bash
792810
set -e
793811
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -850,7 +868,7 @@ pipeline {
850868
"object": "'${COMMIT_SHA}'",\
851869
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to main",\
852870
"type": "commit",\
853-
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
871+
"tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
854872
echo "Pushing New release for Tag"
855873
sh '''#! /bin/bash
856874
echo "Updating PIP version of ${EXT_PIP} to ${EXT_RELEASE_CLEAN}" > releasebody.json
@@ -982,6 +1000,13 @@ EOF
9821000
###################### */
9831001
post {
9841002
always {
1003+
sh '''#!/bin/bash
1004+
rm -rf /config/.ssh/id_sign
1005+
rm -rf /config/.ssh/id_sign.pub
1006+
git config --global --unset gpg.format
1007+
git config --global --unset user.signingkey
1008+
git config --global --unset commit.gpgsign
1009+
'''
9851010
script{
9861011
if (env.EXIT_STATUS == "ABORTED"){
9871012
sh 'echo "build aborted"'
@@ -1011,3 +1036,20 @@ EOF
10111036
}
10121037
}
10131038
}
1039+
1040+
def retry_backoff(int max_attempts, int power_base, Closure c) {
1041+
int n = 0
1042+
while (n < max_attempts) {
1043+
try {
1044+
c()
1045+
return
1046+
} catch (err) {
1047+
if ((n + 1) >= max_attempts) {
1048+
throw err
1049+
}
1050+
sleep(power_base ** n)
1051+
n++
1052+
}
1053+
}
1054+
return
1055+
}

0 commit comments

Comments
 (0)