Skip to content

Commit c4de83b

Browse files
Bot Updating Templated Files
1 parent b646eba commit c4de83b

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
JSON_URL = 'https://plex.tv/api/downloads/5.json'
2123
JSON_PATH = '.computer.Linux.version'
2224
BUILD_VERSION_ARG = 'PLEX_RELEASE'
@@ -38,9 +40,23 @@ pipeline {
3840
CI_WEBPATH='/web/index.html'
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
@@ -383,9 +399,9 @@ pipeline {
383399
echo "Updating Unraid template"
384400
cd ${TEMPDIR}/unraid/templates/
385401
GH_TEMPLATES_DEFAULT_BRANCH=$(git remote show origin | grep "HEAD branch:" | sed 's|.*HEAD branch: ||')
386-
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
402+
if grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list && [[ -f ${TEMPDIR}/unraid/templates/unraid/deprecated/${CONTAINER_NAME}.xml ]]; then
387403
echo "Image is on the ignore list, and already in the deprecation folder."
388-
elif grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
404+
elif grep -wq "^${CONTAINER_NAME}$" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
389405
echo "Image is on the ignore list, marking Unraid template as deprecated"
390406
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
391407
git add -u unraid/${CONTAINER_NAME}.xml
@@ -478,10 +494,10 @@ pipeline {
478494
}
479495
}
480496
/* #######################
481-
GitLab Mirroring
497+
GitLab Mirroring and Quay.io Repo Visibility
482498
####################### */
483-
// Ping into Gitlab to mirror this repo and have a registry endpoint
484-
stage("GitLab Mirror"){
499+
// Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
500+
stage("GitLab Mirror and Quay.io Visibility"){
485501
when {
486502
environment name: 'EXIT_STATUS', value: ''
487503
}
@@ -497,6 +513,8 @@ pipeline {
497513
"visibility":"public"}' '''
498514
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
499515
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
516+
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" \
517+
-d '{"visibility":"public"}' ||: '''
500518
}
501519
}
502520
/* ###############
@@ -591,7 +609,7 @@ pipeline {
591609
--provenance=false --sbom=false \
592610
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
593611
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
594-
retry(5) {
612+
retry_backoff(5,5) {
595613
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
596614
}
597615
sh '''#! /bin/bash
@@ -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
@@ -765,7 +783,7 @@ pipeline {
765783
docker push ${PUSHIMAGE}:${META_TAG}
766784
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
767785
if [ -n "${SEMVER}" ]; then
768-
docker push ${PUSHIMAGE}:${SEMVER}
786+
docker push ${PUSHIMAGE}:${SEMVER}
769787
fi
770788
done
771789
'''
@@ -788,7 +806,7 @@ pipeline {
788806
passwordVariable: 'QUAYPASS'
789807
]
790808
]) {
791-
retry(5) {
809+
retry_backoff(5,5) {
792810
sh '''#! /bin/bash
793811
set -e
794812
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
@@ -851,7 +869,7 @@ pipeline {
851869
"object": "'${COMMIT_SHA}'",\
852870
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
853871
"type": "commit",\
854-
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
872+
"tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
855873
echo "Pushing New release for Tag"
856874
sh '''#! /bin/bash
857875
echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json
@@ -983,6 +1001,13 @@ EOF
9831001
###################### */
9841002
post {
9851003
always {
1004+
sh '''#!/bin/bash
1005+
rm -rf /config/.ssh/id_sign
1006+
rm -rf /config/.ssh/id_sign.pub
1007+
git config --global --unset gpg.format
1008+
git config --global --unset user.signingkey
1009+
git config --global --unset commit.gpgsign
1010+
'''
9861011
script{
9871012
if (env.EXIT_STATUS == "ABORTED"){
9881013
sh 'echo "build aborted"'
@@ -1012,3 +1037,20 @@ EOF
10121037
}
10131038
}
10141039
}
1040+
1041+
def retry_backoff(int max_attempts, int power_base, Closure c) {
1042+
int n = 0
1043+
while (n < max_attempts) {
1044+
try {
1045+
c()
1046+
return
1047+
} catch (err) {
1048+
if ((n + 1) >= max_attempts) {
1049+
throw err
1050+
}
1051+
sleep(power_base ** n)
1052+
n++
1053+
}
1054+
}
1055+
return
1056+
}

0 commit comments

Comments
 (0)