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