Skip to content

Commit 0e7562f

Browse files
Bot Updating Templated Files
1 parent 3c9aa26 commit 0e7562f

File tree

1 file changed

+74
-36
lines changed

1 file changed

+74
-36
lines changed

Jenkinsfile

Lines changed: 74 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ pipeline {
218218
env.META_TAG = env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER
219219
env.EXT_RELEASE_TAG = 'version-' + env.EXT_RELEASE_CLEAN
220220
env.BUILDCACHE = 'docker.io/lsiodev/buildcache,registry.gitlab.com/linuxserver.io/docker-jenkins-builder/lsiodev-buildcache,ghcr.io/linuxserver/lsiodev-buildcache,quay.io/linuxserver.io/lsiodev-buildcache'
221+
env.CITEST_IMAGETAG = 'latest'
221222
}
222223
}
223224
}
@@ -243,6 +244,7 @@ pipeline {
243244
env.EXT_RELEASE_TAG = 'version-' + env.EXT_RELEASE_CLEAN
244245
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.DEV_DOCKERHUB_IMAGE + '/tags/'
245246
env.BUILDCACHE = 'docker.io/lsiodev/buildcache,registry.gitlab.com/linuxserver.io/docker-jenkins-builder/lsiodev-buildcache,ghcr.io/linuxserver/lsiodev-buildcache,quay.io/linuxserver.io/lsiodev-buildcache'
247+
env.CITEST_IMAGETAG = 'develop'
246248
}
247249
}
248250
}
@@ -268,6 +270,7 @@ pipeline {
268270
env.CODE_URL = 'https://github.com/' + env.LS_USER + '/' + env.LS_REPO + '/pull/' + env.PULL_REQUEST
269271
env.DOCKERHUB_LINK = 'https://hub.docker.com/r/' + env.PR_DOCKERHUB_IMAGE + '/tags/'
270272
env.BUILDCACHE = 'docker.io/lsiodev/buildcache,registry.gitlab.com/linuxserver.io/docker-jenkins-builder/lsiodev-buildcache,ghcr.io/linuxserver/lsiodev-buildcache,quay.io/linuxserver.io/lsiodev-buildcache'
273+
env.CITEST_IMAGETAG = 'develop'
271274
}
272275
}
273276
}
@@ -290,7 +293,7 @@ pipeline {
290293
-v ${WORKSPACE}:/mnt \
291294
-e AWS_ACCESS_KEY_ID=\"${S3_KEY}\" \
292295
-e AWS_SECRET_ACCESS_KEY=\"${S3_SECRET}\" \
293-
ghcr.io/linuxserver/baseimage-alpine:3.20 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\
296+
ghcr.io/linuxserver/baseimage-alpine:3 s6-envdir -fn -- /var/run/s6/container_environment /bin/bash -c "\
294297
apk add --no-cache python3 && \
295298
python3 -m venv /lsiopy && \
296299
pip install --no-cache-dir -U pip && \
@@ -591,13 +594,16 @@ pipeline {
591594
echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin
592595
echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin
593596
echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin
597+
594598
if [[ "${PACKAGE_CHECK}" != "true" ]]; then
599+
declare -A pids
595600
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
596601
for i in "${CACHE[@]}"; do
597602
docker push ${i}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} &
603+
pids[$!]="$i"
598604
done
599-
for p in $(jobs -p); do
600-
wait "$p" || { echo "job $p failed" >&2; exit 1; }
605+
for p in "${!pids[@]}"; do
606+
wait "$p" || { [[ "${pids[$p]}" != *"quay.io"* ]] && exit 1; }
601607
done
602608
fi
603609
'''
@@ -657,13 +663,16 @@ pipeline {
657663
echo $GITHUB_TOKEN | docker login ghcr.io -u LinuxServer-CI --password-stdin
658664
echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin
659665
echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin
666+
660667
if [[ "${PACKAGE_CHECK}" != "true" ]]; then
668+
declare -A pids
661669
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
662670
for i in "${CACHE[@]}"; do
663671
docker push ${i}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} &
672+
pids[$!]="$i"
664673
done
665-
for p in $(jobs -p); do
666-
wait "$p" || { echo "job $p failed" >&2; exit 1; }
674+
for p in "${!pids[@]}"; do
675+
wait "$p" || { [[ "${pids[$p]}" != *"quay.io"* ]] && exit 1; }
667676
done
668677
fi
669678
'''
@@ -717,12 +726,14 @@ pipeline {
717726
echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin
718727
echo $QUAYPASS | docker login quay.io -u $QUAYUSER --password-stdin
719728
if [[ "${PACKAGE_CHECK}" != "true" ]]; then
729+
declare -A pids
720730
IFS=',' read -ra CACHE <<< "$BUILDCACHE"
721731
for i in "${CACHE[@]}"; do
722732
docker push ${i}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} &
733+
pids[$!]="$i"
723734
done
724-
for p in $(jobs -p); do
725-
wait "$p" || { echo "job $p failed" >&2; exit 1; }
735+
for p in "${!pids[@]}"; do
736+
wait "$p" || { [[ "${pids[$p]}" != *"quay.io"* ]] && exit 1; }
726737
done
727738
fi
728739
'''
@@ -847,7 +858,7 @@ pipeline {
847858
CI_DOCKERENV="LSIO_FIRST_PARTY=true"
848859
fi
849860
fi
850-
docker pull ghcr.io/linuxserver/ci:latest
861+
docker pull ghcr.io/linuxserver/ci:${CITEST_IMAGETAG}
851862
if [ "${MULTIARCH}" == "true" ]; then
852863
docker pull ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} --platform=arm64
853864
docker tag ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} ${IMAGE}:arm64v8-${META_TAG}
@@ -871,7 +882,7 @@ pipeline {
871882
-e WEB_PATH=\"${CI_WEBPATH}\" \
872883
-e NODE_NAME=\"${NODE_NAME}\" \
873884
-e SYFT_IMAGE_TAG=\"${CI_SYFT_IMAGE_TAG:-${SYFT_IMAGE_TAG}}\" \
874-
-t ghcr.io/linuxserver/ci:latest \
885+
-t ghcr.io/linuxserver/ci:${CITEST_IMAGETAG} \
875886
python3 test_build.py'''
876887
}
877888
}
@@ -897,9 +908,11 @@ pipeline {
897908
CACHEIMAGE=${i}
898909
fi
899910
done
900-
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${META_TAG} -t ${PUSHIMAGE}:latest -t ${PUSHIMAGE}:${EXT_RELEASE_TAG} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER}
911+
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${META_TAG} -t ${PUSHIMAGE}:latest -t ${PUSHIMAGE}:${EXT_RELEASE_TAG} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \
912+
{ if [[ "${PUSHIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
901913
if [ -n "${SEMVER}" ]; then
902-
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER}
914+
docker buildx imagetools create --prefer-index=false -t ${PUSHIMAGE}:${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \
915+
{ if [[ "${PUSHIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
903916
fi
904917
done
905918
'''
@@ -924,20 +937,27 @@ pipeline {
924937
CACHEIMAGE=${i}
925938
fi
926939
done
927-
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:amd64-${META_TAG} -t ${MANIFESTIMAGE}:amd64-latest -t ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER}
928-
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:arm64v8-${META_TAG} -t ${MANIFESTIMAGE}:arm64v8-latest -t ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} ${CACHEIMAGE}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}
940+
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:amd64-${META_TAG} -t ${MANIFESTIMAGE}:amd64-latest -t ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \
941+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
942+
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:arm64v8-${META_TAG} -t ${MANIFESTIMAGE}:arm64v8-latest -t ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} ${CACHEIMAGE}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || \
943+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
929944
if [ -n "${SEMVER}" ]; then
930-
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:amd64-${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER}
931-
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:arm64v8-${SEMVER} ${CACHEIMAGE}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}
945+
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:amd64-${SEMVER} ${CACHEIMAGE}:amd64-${COMMIT_SHA}-${BUILD_NUMBER} || \
946+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
947+
docker buildx imagetools create --prefer-index=false -t ${MANIFESTIMAGE}:arm64v8-${SEMVER} ${CACHEIMAGE}:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER} || \
948+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
932949
fi
933950
done
934951
for MANIFESTIMAGE in "${IMAGE}" "${GITLABIMAGE}" "${GITHUBIMAGE}" "${QUAYIMAGE}"; do
935-
docker buildx imagetools create -t ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm64v8-latest
936-
docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG}
937-
938-
docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG}
952+
docker buildx imagetools create -t ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm64v8-latest || \
953+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
954+
docker buildx imagetools create -t ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} || \
955+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
956+
docker buildx imagetools create -t ${MANIFESTIMAGE}:${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:amd64-${EXT_RELEASE_TAG} ${MANIFESTIMAGE}:arm64v8-${EXT_RELEASE_TAG} || \
957+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
939958
if [ -n "${SEMVER}" ]; then
940-
docker buildx imagetools create -t ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER}
959+
docker buildx imagetools create -t ${MANIFESTIMAGE}:${SEMVER} ${MANIFESTIMAGE}:amd64-${SEMVER} ${MANIFESTIMAGE}:arm64v8-${SEMVER} || \
960+
{ if [[ "${MANIFESTIMAGE}" != "${QUAYIMAGE}" ]]; then exit 1; fi; }
941961
fi
942962
done
943963
'''
@@ -955,23 +975,41 @@ pipeline {
955975
environment name: 'EXIT_STATUS', value: ''
956976
}
957977
steps {
958-
echo "Pushing New tag for current commit ${META_TAG}"
959-
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \
960-
-d '{"tag":"'${META_TAG}'",\
961-
"object": "'${COMMIT_SHA}'",\
962-
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
963-
"type": "commit",\
964-
"tagger": {"name": "LinuxServer-CI","email": "[email protected]","date": "'${GITHUB_DATE}'"}}' '''
965-
echo "Pushing New release for Tag"
966978
sh '''#! /bin/bash
967-
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
968-
echo '{"tag_name":"'${META_TAG}'",\
969-
"target_commitish": "master",\
970-
"name": "'${META_TAG}'",\
971-
"body": "**CI Report:**\\n\\n'${CI_URL:-N/A}'\\n\\n**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n\\n**Remote Changes:**\\n\\n' > start
972-
printf '","draft": false,"prerelease": false}' >> releasebody.json
973-
paste -d'\\0' start releasebody.json > releasebody.json.done
974-
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done'''
979+
echo "Auto-generating release notes"
980+
if [ "$(git tag --points-at HEAD)" != "" ]; then
981+
echo "Existing tag points to current commit, suggesting no new LS changes"
982+
AUTO_RELEASE_NOTES="No changes"
983+
else
984+
AUTO_RELEASE_NOTES=$(curl -fsL -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github+json" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases/generate-notes \
985+
-d '{"tag_name":"'${META_TAG}'",\
986+
"target_commitish": "master"}' \
987+
| jq -r '.body' | sed 's|## What.s Changed||')
988+
fi
989+
echo "Pushing New tag for current commit ${META_TAG}"
990+
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \
991+
-d '{"tag":"'${META_TAG}'",\
992+
"object": "'${COMMIT_SHA}'",\
993+
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\
994+
"type": "commit",\
995+
"tagger": {"name": "LinuxServer-CI","email": "[email protected]","date": "'${GITHUB_DATE}'"}}'
996+
echo "Pushing New release for Tag"
997+
curl -H "Authorization: token ${GITHUB_TOKEN}" -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. |.body' > releasebody.json
998+
jq -n \
999+
--arg tag_name "$META_TAG" \
1000+
--arg target_commitish "master" \
1001+
--arg ci_url "${CI_URL:-N/A}" \
1002+
--arg ls_notes "$AUTO_RELEASE_NOTES" \
1003+
--arg remote_notes "$(cat releasebody.json)" \
1004+
'{
1005+
"tag_name": $tag_name,
1006+
"target_commitish": $target_commitish,
1007+
"name": $tag_name,
1008+
"body": ("**CI Report:**\\n\\n" + $ci_url + "\\n\\n**LinuxServer Changes:**\\n\\n" + $ls_notes + "\\n\\n**Remote Changes:**\\n\\n" + $remote_notes),
1009+
"draft": false,
1010+
"prerelease": false }' > releasebody.json.done
1011+
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done
1012+
'''
9751013
}
9761014
}
9771015
// Add protection to the release branch

0 commit comments

Comments
 (0)