@@ -233,22 +233,67 @@ pipeline {
233
233
TEMPDIR=$(mktemp -d)
234
234
docker pull ghcr.io/linuxserver/jenkins-builder:latest
235
235
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=master -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest
236
+ # Stage 1 - Jenkinsfile update
237
+ if [[ "$(md5sum Jenkinsfile | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile | awk '{ print $1 }')" ]]; then
238
+ mkdir -p ${TEMPDIR}/repo
239
+ git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
240
+ cd ${TEMPDIR}/repo/${LS_REPO}
241
+ git checkout -f master
242
+ cp ${TEMPDIR}/docker-${CONTAINER_NAME}/Jenkinsfile ${TEMPDIR}/repo/${LS_REPO}/
243
+ git add Jenkinsfile
244
+ git commit -m 'Bot Updating Templated Files'
245
+ git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all
246
+ echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER}
247
+ echo "Updating Jenkinsfile"
248
+ rm -Rf ${TEMPDIR}
249
+ exit 0
250
+ else
251
+ echo "Jenkinsfile is up to date."
252
+ fi
253
+ # Stage 2 - Delete old templates
254
+ OLD_TEMPLATES=".github/ISSUE_TEMPLATE.md"
255
+ for i in ${OLD_TEMPLATES}; do
256
+ if [[ -f "${i}" ]]; then
257
+ TEMPLATES_TO_DELETE="${i} ${TEMPLATES_TO_DELETE}"
258
+ fi
259
+ done
260
+ if [[ -n "${TEMPLATES_TO_DELETE}" ]]; then
261
+ mkdir -p ${TEMPDIR}/repo
262
+ git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
263
+ cd ${TEMPDIR}/repo/${LS_REPO}
264
+ git checkout -f master
265
+ cd ${TEMPDIR}/docker-${CONTAINER_NAME}
266
+ for i in ${TEMPLATES_TO_DELETE}; do
267
+ git rm "${i}"
268
+ done
269
+ git commit -m 'Bot Updating Templated Files'
270
+ git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all
271
+ echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER}
272
+ echo "Deleting old templates"
273
+ rm -Rf ${TEMPDIR}
274
+ exit 0
275
+ else
276
+ echo "No templates to delete"
277
+ fi
278
+ # Stage 3 - Update templates
236
279
CURRENTHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8)
237
280
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
238
281
NEWHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8)
239
- if [[ "${CURRENTHASH}" != "${NEWHASH}" ]]; then
282
+ if [[ "${CURRENTHASH}" != "${NEWHASH}" ]] || ! grep -q '.jenkins-external' "${WORKSPACE}/.gitignore" 2>/dev/null ; then
240
283
mkdir -p ${TEMPDIR}/repo
241
284
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO}
242
285
cd ${TEMPDIR}/repo/${LS_REPO}
243
286
git checkout -f master
244
287
cd ${TEMPDIR}/docker-${CONTAINER_NAME}
245
288
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/workflows
246
289
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE
247
- rm -f ${TEMPDIR}/repo/${LS_REPO}/.github/ISSUE_TEMPLATE.md
248
290
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ || :
249
291
cd ${TEMPDIR}/repo/${LS_REPO}/
292
+ if ! grep -q '.jenkins-external' .gitignore 2>/dev/null; then
293
+ echo ".jenkins-external" >> .gitignore
294
+ git add .gitignore
295
+ fi
250
296
git add ${TEMPLATED_FILES}
251
- git rm .github/ISSUE_TEMPLATE.md || :
252
297
git commit -m 'Bot Updating Templated Files'
253
298
git push https://LinuxServer-CI:${GITHUB_TOKEN}@github.com/${LS_USER}/${LS_REPO}.git --all
254
299
echo "true" > /tmp/${COMMIT_SHA}-${BUILD_NUMBER}
@@ -257,8 +302,8 @@ pipeline {
257
302
fi
258
303
mkdir -p ${TEMPDIR}/gitbook
259
304
git clone https://github.com/linuxserver/docker-documentation.git ${TEMPDIR}/gitbook/docker-documentation
260
- if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then
261
- cp ${TEMPDIR}/docker-${CONTAINER_NAME}/docker-${CONTAINER_NAME}.md ${TEMPDIR}/gitbook/docker-documentation/images/
305
+ if [[ ("${BRANCH_NAME}" == "master") || ("${BRANCH_NAME}" == "main") ]] && [[ (! -f ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md) || ("$(md5sum ${TEMPDIR}/gitbook/docker-documentation/images/docker-${CONTAINER_NAME}.md | awk '{ print $1 }')" != "$(md5sum ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/ docker-${CONTAINER_NAME}.md | awk '{ print $1 }')") ]]; then
306
+ cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/ docker-${CONTAINER_NAME}.md ${TEMPDIR}/gitbook/docker-documentation/images/
262
307
cd ${TEMPDIR}/gitbook/docker-documentation/
263
308
git add images/docker-${CONTAINER_NAME}.md
264
309
git commit -m 'Bot Updating Documentation'
@@ -268,13 +313,13 @@ pipeline {
268
313
git clone https://github.com/linuxserver/docker-templates.git ${TEMPDIR}/unraid/docker-templates
269
314
git clone https://github.com/linuxserver/templates.git ${TEMPDIR}/unraid/templates
270
315
if [[ -f ${TEMPDIR}/unraid/docker-templates/linuxserver.io/img/${CONTAINER_NAME}-icon.png ]]; then
271
- sed -i "s|master/linuxserver.io/img/linuxserver-ls-logo.png|master/linuxserver.io/img/${CONTAINER_NAME}-icon.png|" ${TEMPDIR}/docker-${CONTAINER_NAME}/${CONTAINER_NAME}.xml
316
+ 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
272
317
fi
273
- 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}/${CONTAINER_NAME}.xml | awk '{ print $1 }')") ]]; then
318
+ 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
274
319
if grep -wq "${CONTAINER_NAME}" ${TEMPDIR}/unraid/templates/unraid/ignore.list; then
275
320
echo "Image is on the ignore list, skipping Unraid template upload"
276
321
else
277
- cp ${TEMPDIR}/docker-${CONTAINER_NAME}/${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
322
+ cp ${TEMPDIR}/docker-${CONTAINER_NAME}/.jenkins-external/ ${CONTAINER_NAME}.xml ${TEMPDIR}/unraid/templates/unraid/
278
323
cd ${TEMPDIR}/unraid/templates/
279
324
git add unraid/${CONTAINER_NAME}.xml
280
325
git commit -m 'Bot Updating Unraid Template'
@@ -514,7 +559,7 @@ pipeline {
514
559
}
515
560
sh ''' #! /bin/bash
516
561
set -e
517
- docker pull ghcr.io/linuxserver/lsiodev- ci:latest
562
+ docker pull ghcr.io/linuxserver/ci:latest
518
563
if [ "${MULTIARCH}" == "true" ]; then
519
564
docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER}
520
565
docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}
@@ -539,7 +584,7 @@ pipeline {
539
584
-e WEB_PATH=\" ${CI_WEBPATH}\" \
540
585
-e DO_REGION="ams3" \
541
586
-e DO_BUCKET="lsio-ci" \
542
- -t ghcr.io/linuxserver/lsiodev- ci:latest \
587
+ -t ghcr.io/linuxserver/ci:latest \
543
588
python /ci/ci.py'''
544
589
}
545
590
}
@@ -684,19 +729,19 @@ pipeline {
684
729
environment name : ' EXIT_STATUS' , value : ' '
685
730
}
686
731
steps {
687
- echo " Pushing New tag for current commit ${ EXT_RELEASE_CLEAN } -ls ${ LS_TAG_NUMBER } "
732
+ echo " Pushing New tag for current commit ${ META_TAG } "
688
733
sh ''' curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \
689
- -d '{"tag":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER }'",\
734
+ -d '{"tag":"'${META_TAG }'",\
690
735
"object": "'${COMMIT_SHA}'",\
691
736
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
692
737
"type": "commit",\
693
738
"tagger": {"name": "LinuxServer Jenkins","email": "[email protected] ","date": "'${GITHUB_DATE}'"}}' '''
694
739
echo " Pushing New release for Tag"
695
740
sh ''' #! /bin/bash
696
741
echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json
697
- echo '{"tag_name":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER }'",\
742
+ echo '{"tag_name":"'${META_TAG }'",\
698
743
"target_commitish": "master",\
699
- "name": "'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER }'",\
744
+ "name": "'${META_TAG }'",\
700
745
"body": "**LinuxServer Changes:**\\ n\\ n'${LS_RELEASE_NOTES}'\\ n**Remote Changes:**\\ n\\ n' > start
701
746
printf '","draft": false,"prerelease": false}' >> releasebody.json
702
747
paste -d'\\ 0' start releasebody.json > releasebody.json.done
@@ -723,15 +768,15 @@ pipeline {
723
768
TEMPDIR=$(mktemp -d)
724
769
docker pull ghcr.io/linuxserver/jenkins-builder:latest
725
770
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH="${BRANCH_NAME}" -v ${TEMPDIR}:/ansible/jenkins ghcr.io/linuxserver/jenkins-builder:latest
726
- docker pull ghcr.io/linuxserver/lsiodev- readme-sync
771
+ docker pull ghcr.io/linuxserver/readme-sync
727
772
docker run --rm=true \
728
773
-e DOCKERHUB_USERNAME=$DOCKERUSER \
729
774
-e DOCKERHUB_PASSWORD=$DOCKERPASS \
730
775
-e GIT_REPOSITORY=${LS_USER}/${LS_REPO} \
731
776
-e DOCKER_REPOSITORY=${IMAGE} \
732
777
-e GIT_BRANCH=master \
733
778
-v ${TEMPDIR}/docker-${CONTAINER_NAME}:/mnt \
734
- ghcr.io/linuxserver/lsiodev- readme-sync bash -c 'node sync'
779
+ ghcr.io/linuxserver/readme-sync bash -c 'node sync'
735
780
rm -Rf ${TEMPDIR} '''
736
781
}
737
782
}
0 commit comments