Skip to content

Commit d7173ba

Browse files
Bot Updating Templated Files
1 parent b0dc043 commit d7173ba

File tree

1 file changed

+73
-19
lines changed

1 file changed

+73
-19
lines changed

Jenkinsfile

+73-19
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pipeline {
5858
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/commit/' + env.GIT_COMMIT
5959
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DOCKERHUB_IMAGE + '/tags/'
6060
env.PULL_REQUEST = env.CHANGE_ID
61-
env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.md ./.github/ISSUE_TEMPLATE/issue.feature.md ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/greetings.yml ./.github/workflows/stale.yml ./.github/workflows/package_trigger.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/external_trigger.yml ./.github/workflows/external_trigger_scheduler.yml'
61+
env.TEMPLATED_FILES = 'Jenkinsfile README.md LICENSE ./.github/CONTRIBUTING.md ./.github/FUNDING.yml ./.github/ISSUE_TEMPLATE/config.yml ./.github/ISSUE_TEMPLATE/issue.bug.md ./.github/ISSUE_TEMPLATE/issue.feature.md ./.github/PULL_REQUEST_TEMPLATE.md ./.github/workflows/external_trigger_scheduler.yml ./.github/workflows/greetings.yml ./.github/workflows/package_trigger_scheduler.yml ./.github/workflows/stale.yml ./.github/workflows/external_trigger.yml ./.github/workflows/package_trigger.yml'
6262
}
6363
script{
6464
env.LS_RELEASE_NUMBER = sh(
@@ -106,7 +106,7 @@ pipeline {
106106
steps{
107107
script{
108108
env.EXT_RELEASE = sh(
109-
script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''',
109+
script: '''curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''',
110110
returnStdout: true).trim()
111111
}
112112
}
@@ -317,22 +317,24 @@ pipeline {
317317
git commit -m 'Bot Updating Documentation'
318318
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/docker-documentation.git --all
319319
fi
320-
mkdir -p ${TEMPDIR}/unraid
320+
mkdir -p ${TEMPDIR}/unraid
321321
git clone https://github.com/linuxserver/docker-templates.git ${TEMPDIR}/unraid/docker-templates
322322
git clone https://github.com/linuxserver/templates.git ${TEMPDIR}/unraid/templates
323-
if [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-icon.png ]]; then
324-
sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-icon.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml
323+
if [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-logo.png ]]; then
324+
sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-logo.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml
325325
fi
326326
if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml) || ("$(md5sum ${TEMPDIR}/unraid/templates/unraid/${CONTAINER_NAME}.xml | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then
327+
cd ${TEMPDIR}/unraid/templates/
327328
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
328-
echo "Image is on the ignore list, skipping Unraid template upload"
329+
echo "Image is on the ignore list, removing Unraid template"
330+
git rm unraid/${CONTAINER_NAME}.xml || :
331+
git commit -m 'Bot Removing Deprecated Unraid Template' || :
329332
else
330333
cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
331-
cd ${TEMPDIR}/unraid/templates/
332334
git add unraid/${CONTAINER_NAME}.xml
333335
git commit -m 'Bot Updating Unraid Template'
334-
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git --all
335336
fi
337+
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/linuxserver/templates.git --all
336338
fi
337339
rm -Rf ${TEMPDIR}'''
338340
script{
@@ -389,8 +391,21 @@ pipeline {
389391
}
390392
steps {
391393
echo "Running on node: ${NODE_NAME}"
392-
sh "docker build --no-cache --pull -t ${IMAGE}:${META_TAG} \
393-
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
394+
sh "docker build \
395+
--label \"org.opencontainers.image.created=${GITHUB_DATE}\" \
396+
--label \"org.opencontainers.image.authors=linuxserver.io\" \
397+
--label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-syncthing/packages\" \
398+
--label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-syncthing\" \
399+
--label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-syncthing\" \
400+
--label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \
401+
--label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \
402+
--label \"org.opencontainers.image.vendor=linuxserver.io\" \
403+
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
404+
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
405+
--label \"org.opencontainers.image.title=Syncthing\" \
406+
--label \"org.opencontainers.image.description=[Syncthing](https://syncthing.net) replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet.\" \
407+
--no-cache --pull -t ${IMAGE}:${META_TAG} \
408+
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
394409
}
395410
}
396411
// Build MultiArch Docker containers for push to LS Repo
@@ -403,8 +418,21 @@ pipeline {
403418
stage('Build X86') {
404419
steps {
405420
echo "Running on node: ${NODE_NAME}"
406-
sh "docker build --no-cache --pull -t ${IMAGE}:amd64-${META_TAG} \
407-
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
421+
sh "docker build \
422+
--label \"org.opencontainers.image.created=${GITHUB_DATE}\" \
423+
--label \"org.opencontainers.image.authors=linuxserver.io\" \
424+
--label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-syncthing/packages\" \
425+
--label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-syncthing\" \
426+
--label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-syncthing\" \
427+
--label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \
428+
--label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \
429+
--label \"org.opencontainers.image.vendor=linuxserver.io\" \
430+
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
431+
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
432+
--label \"org.opencontainers.image.title=Syncthing\" \
433+
--label \"org.opencontainers.image.description=[Syncthing](https://syncthing.net) replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet.\" \
434+
--no-cache --pull -t ${IMAGE}:amd64-${META_TAG} \
435+
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
408436
}
409437
}
410438
stage('Build ARMHF') {
@@ -417,8 +445,21 @@ pipeline {
417445
sh '''#! /bin/bash
418446
echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin
419447
'''
420-
sh "docker build --no-cache --pull -f Dockerfile.armhf -t ${IMAGE}:arm32v7-${META_TAG} \
421-
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
448+
sh "docker build \
449+
--label \"org.opencontainers.image.created=${GITHUB_DATE}\" \
450+
--label \"org.opencontainers.image.authors=linuxserver.io\" \
451+
--label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-syncthing/packages\" \
452+
--label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-syncthing\" \
453+
--label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-syncthing\" \
454+
--label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \
455+
--label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \
456+
--label \"org.opencontainers.image.vendor=linuxserver.io\" \
457+
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
458+
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
459+
--label \"org.opencontainers.image.title=Syncthing\" \
460+
--label \"org.opencontainers.image.description=[Syncthing](https://syncthing.net) replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet.\" \
461+
--no-cache --pull -f Dockerfile.armhf -t ${IMAGE}:arm32v7-${META_TAG} \
462+
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
422463
sh "docker tag ${IMAGE}:arm32v7-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}"
423464
retry(5) {
424465
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}"
@@ -438,8 +479,21 @@ pipeline {
438479
sh '''#! /bin/bash
439480
echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin
440481
'''
441-
sh "docker build --no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} \
442-
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
482+
sh "docker build \
483+
--label \"org.opencontainers.image.created=${GITHUB_DATE}\" \
484+
--label \"org.opencontainers.image.authors=linuxserver.io\" \
485+
--label \"org.opencontainers.image.url=https://github.com/linuxserver/docker-syncthing/packages\" \
486+
--label \"org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-syncthing\" \
487+
--label \"org.opencontainers.image.source=https://github.com/linuxserver/docker-syncthing\" \
488+
--label \"org.opencontainers.image.version=${EXT_RELEASE_CLEAN}-ls${LS_TAG_NUMBER}\" \
489+
--label \"org.opencontainers.image.revision=${COMMIT_SHA}\" \
490+
--label \"org.opencontainers.image.vendor=linuxserver.io\" \
491+
--label \"org.opencontainers.image.licenses=GPL-3.0-only\" \
492+
--label \"org.opencontainers.image.ref.name=${COMMIT_SHA}\" \
493+
--label \"org.opencontainers.image.title=Syncthing\" \
494+
--label \"org.opencontainers.image.description=[Syncthing](https://syncthing.net) replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet.\" \
495+
--no-cache --pull -f Dockerfile.aarch64 -t ${IMAGE}:arm64v8-${META_TAG} \
496+
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
443497
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
444498
retry(5) {
445499
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
@@ -746,11 +800,11 @@ pipeline {
746800
"tagger": {"name": "LinuxServer Jenkins","email": "[email protected]","date": "'${GITHUB_DATE}'"}}' '''
747801
echo "Pushing New release for Tag"
748802
sh '''#! /bin/bash
749-
curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json
803+
curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json
750804
echo '{"tag_name":"'${META_TAG}'",\
751805
"target_commitish": "master",\
752806
"name": "'${META_TAG}'",\
753-
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start
807+
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**'${EXT_REPO}' Changes:**\\n\\n' > start
754808
printf '","draft": false,"prerelease": false}' >> releasebody.json
755809
paste -d'\\0' start releasebody.json > releasebody.json.done
756810
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
@@ -775,7 +829,7 @@ pipeline {
775829
set -e
776830
TEMPDIR=$(mktemp -d)
777831
docker pull ghcr.io/linuxserver/jenkins-builder:latest
778-
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH="${BRANCH_NAME}" -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest
832+
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH="${BRANCH_NAME}" -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest
779833
docker pull ghcr.io/linuxserver/readme-sync
780834
docker run --rm=true \
781835
-e DOCKERHUB_USERNAME=$DOCKERUSER \

0 commit comments

Comments
 (0)