-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ pipeline { | |
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0') | ||
GITLAB_NAMESPACE=credentials('gitlab-namespace-id') | ||
CONTAINER_NAME = 'netbootxyz' | ||
BUILD_VERSION_ARG = 'NETBOOTXYZ_SHA' | ||
BUILD_VERSION_ARG = 'NETBOOTXYZ_RELEASE' | ||
LS_USER = 'linuxserver' | ||
LS_REPO = 'docker-netbootxyz' | ||
DOCKERHUB_IMAGE = 'linuxserver/netbootxyz' | ||
|
@@ -41,7 +41,7 @@ pipeline { | |
script{ | ||
env.EXIT_STATUS = '' | ||
env.LS_RELEASE = sh( | ||
script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':latest 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', | ||
script: '''docker run --rm alexeiled/skopeo sh -c 'skopeo inspect docker://docker.io/'${DOCKERHUB_IMAGE}':tftp 2>/dev/null' | jq -r '.Labels.build_version' | awk '{print $3}' | grep '\\-ls' || : ''', | ||
returnStdout: true).trim() | ||
env.LS_RELEASE_NOTES = sh( | ||
script: '''cat readme-vars.yml | awk -F \\" '/date: "[0-9][0-9].[0-9][0-9].[0-9][0-9]:/ {print $4;exit;}' | sed -E ':a;N;$!ba;s/\\r{0,1}\\n/\\\\n/g' ''', | ||
|
@@ -98,16 +98,23 @@ pipeline { | |
/* ######################## | ||
External Release Tagging | ||
######################## */ | ||
// If this is a custom command to determine version use that command | ||
stage("Set tag custom bash"){ | ||
steps{ | ||
script{ | ||
env.EXT_RELEASE = sh( | ||
script: ''' curl -sL https://boot.netboot.xyz/ipxe/netboot.xyz-sha256-checksums.txt | grep 'netboot.xyz.kpxe' | cut -c1-8 ''', | ||
returnStdout: true).trim() | ||
env.RELEASE_LINK = 'custom_command' | ||
} | ||
} | ||
// If this is a stable github release use the latest endpoint from github to determine the ext tag | ||
stage("Set ENV github_stable"){ | ||
steps{ | ||
script{ | ||
env.EXT_RELEASE = sh( | ||
script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''', | ||
returnStdout: true).trim() | ||
} | ||
} | ||
} | ||
// If this is a stable or devel github release generate the link for the build message | ||
stage("Set ENV github_link"){ | ||
steps{ | ||
script{ | ||
env.RELEASE_LINK = 'https://github.com/' + env.EXT_USER + '/' + env.EXT_REPO + '/releases/tag/' + env.EXT_RELEASE | ||
} | ||
} | ||
} | ||
// Sanitize the release tag and strip illegal docker or github characters | ||
stage("Sanitize tag"){ | ||
|
@@ -119,10 +126,10 @@ pipeline { | |
} | ||
} | ||
} | ||
// If this is a master build use live docker endpoints | ||
// If this is a tftp build use live docker endpoints | ||
stage("Set ENV live build"){ | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
environment name: 'CHANGE_ID', value: '' | ||
} | ||
steps { | ||
|
@@ -143,7 +150,7 @@ pipeline { | |
// If this is a dev build use dev docker endpoints | ||
stage("Set ENV dev build"){ | ||
when { | ||
not {branch "master"} | ||
not {branch "tftp"} | ||
environment name: 'CHANGE_ID', value: '' | ||
} | ||
steps { | ||
|
@@ -216,7 +223,7 @@ pipeline { | |
// Use helper containers to render templated files | ||
stage('Update-Templates') { | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
environment name: 'CHANGE_ID', value: '' | ||
expression { | ||
env.CONTAINER_NAME != null | ||
|
@@ -227,15 +234,15 @@ pipeline { | |
set -e | ||
TEMPDIR=$(mktemp -d) | ||
docker pull linuxserver/jenkins-builder:latest | ||
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=master -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest | ||
docker run --rm -e CONTAINER_NAME=${CONTAINER_NAME} -e GITHUB_BRANCH=tftp -v ${TEMPDIR}:/ansible/jenkins linuxserver/jenkins-builder:latest | ||
CURRENTHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8) | ||
cd ${TEMPDIR}/docker-${CONTAINER_NAME} | ||
NEWHASH=$(grep -hs ^ ${TEMPLATED_FILES} | md5sum | cut -c1-8) | ||
if [[ "${CURRENTHASH}" != "${NEWHASH}" ]]; then | ||
mkdir -p ${TEMPDIR}/repo | ||
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/repo/${LS_REPO} | ||
cd ${TEMPDIR}/repo/${LS_REPO} | ||
git checkout -f master | ||
git checkout -f tftp | ||
cd ${TEMPDIR}/docker-${CONTAINER_NAME} | ||
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github | ||
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ | ||
|
@@ -267,7 +274,7 @@ pipeline { | |
// Exit the build if the Templated files were just updated | ||
stage('Template-exit') { | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'FILES_UPDATED', value: 'true' | ||
expression { | ||
|
@@ -386,7 +393,7 @@ pipeline { | |
// Take the image we just built and dump package versions for comparison | ||
stage('Update-packages') { | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'EXIT_STATUS', value: '' | ||
} | ||
|
@@ -414,7 +421,7 @@ pipeline { | |
echo "Package tag sha from current packages in buit container is ${NEW_PACKAGE_TAG} comparing to old ${PACKAGE_TAG} from github" | ||
if [ "${NEW_PACKAGE_TAG}" != "${PACKAGE_TAG}" ]; then | ||
git clone https://github.com/${LS_USER}/${LS_REPO}.git ${TEMPDIR}/${LS_REPO} | ||
git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f master | ||
git --git-dir ${TEMPDIR}/${LS_REPO}/.git checkout -f tftp | ||
cp ${TEMPDIR}/package_versions.txt ${TEMPDIR}/${LS_REPO}/ | ||
cd ${TEMPDIR}/${LS_REPO}/ | ||
wait | ||
|
@@ -438,7 +445,7 @@ pipeline { | |
// Exit the build if the package file was just updated | ||
stage('PACKAGE-exit') { | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'PACKAGE_UPDATED', value: 'true' | ||
environment name: 'EXIT_STATUS', value: '' | ||
|
@@ -452,7 +459,7 @@ pipeline { | |
// Exit the build if this is just a package check and there are no changes to push | ||
stage('PACKAGECHECK-exit') { | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'PACKAGE_UPDATED', value: 'false' | ||
environment name: 'EXIT_STATUS', value: '' | ||
|
@@ -547,14 +554,14 @@ pipeline { | |
echo $GITLAB_TOKEN | docker login registry.gitlab.com -u LinuxServer.io --password-stdin | ||
for PUSHIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do | ||
docker tag ${IMAGE}:${META_TAG} ${PUSHIMAGE}:${META_TAG} | ||
docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:latest | ||
docker push ${PUSHIMAGE}:latest | ||
docker tag ${PUSHIMAGE}:${META_TAG} ${PUSHIMAGE}:tftp | ||
docker push ${PUSHIMAGE}:tftp | ||
docker push ${PUSHIMAGE}:${META_TAG} | ||
done | ||
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "{GITLABIMAGE}" "${IMAGE}"; do | ||
docker rmi \ | ||
${DELETEIMAGE}:${META_TAG} \ | ||
${DELETEIMAGE}:latest || : | ||
${DELETEIMAGE}:tftp || : | ||
done | ||
''' | ||
} | ||
|
@@ -597,52 +604,52 @@ pipeline { | |
docker tag ${IMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} | ||
docker tag ${IMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} | ||
docker tag ${IMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} | ||
docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-latest | ||
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-latest | ||
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-latest | ||
docker tag ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:amd64-tftp | ||
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-tftp | ||
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-tftp | ||
docker push ${MANIFESTIMAGE}:amd64-${META_TAG} | ||
docker push ${MANIFESTIMAGE}:arm32v7-${META_TAG} | ||
docker push ${MANIFESTIMAGE}:arm64v8-${META_TAG} | ||
docker push ${MANIFESTIMAGE}:amd64-latest | ||
docker push ${MANIFESTIMAGE}:arm32v7-latest | ||
docker push ${MANIFESTIMAGE}:arm64v8-latest | ||
docker manifest push --purge ${MANIFESTIMAGE}:latest || : | ||
docker manifest create ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:amd64-latest ${MANIFESTIMAGE}:arm32v7-latest ${MANIFESTIMAGE}:arm64v8-latest | ||
docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm32v7-latest --os linux --arch arm | ||
docker manifest annotate ${MANIFESTIMAGE}:latest ${MANIFESTIMAGE}:arm64v8-latest --os linux --arch arm64 --variant v8 | ||
docker push ${MANIFESTIMAGE}:amd64-tftp | ||
docker push ${MANIFESTIMAGE}:arm32v7-tftp | ||
docker push ${MANIFESTIMAGE}:arm64v8-tftp | ||
docker manifest push --purge ${MANIFESTIMAGE}:tftp || : | ||
docker manifest create ${MANIFESTIMAGE}:tftp ${MANIFESTIMAGE}:amd64-tftp ${MANIFESTIMAGE}:arm32v7-tftp ${MANIFESTIMAGE}:arm64v8-tftp | ||
docker manifest annotate ${MANIFESTIMAGE}:tftp ${MANIFESTIMAGE}:arm32v7-tftp --os linux --arch arm | ||
docker manifest annotate ${MANIFESTIMAGE}:tftp ${MANIFESTIMAGE}:arm64v8-tftp --os linux --arch arm64 --variant v8 | ||
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} || : | ||
docker manifest create ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:amd64-${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} | ||
docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm32v7-${META_TAG} --os linux --arch arm | ||
docker manifest annotate ${MANIFESTIMAGE}:${META_TAG} ${MANIFESTIMAGE}:arm64v8-${META_TAG} --os linux --arch arm64 --variant v8 | ||
docker manifest push --purge ${MANIFESTIMAGE}:latest | ||
docker manifest push --purge ${MANIFESTIMAGE}:tftp | ||
docker manifest push --purge ${MANIFESTIMAGE}:${META_TAG} | ||
done | ||
for LEGACYIMAGE in "${GITHUBIMAGE}" "${QUAYIMAGE}"; do | ||
docker tag ${IMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:amd64-${META_TAG} | ||
docker tag ${IMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-${META_TAG} | ||
docker tag ${IMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-${META_TAG} | ||
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:latest | ||
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:tftp | ||
docker tag ${LEGACYIMAGE}:amd64-${META_TAG} ${LEGACYIMAGE}:${META_TAG} | ||
docker tag ${LEGACYIMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-latest | ||
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-latest | ||
docker tag ${LEGACYIMAGE}:arm32v7-${META_TAG} ${LEGACYIMAGE}:arm32v7-tftp | ||
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-tftp | ||
docker push ${LEGACYIMAGE}:amd64-${META_TAG} | ||
docker push ${LEGACYIMAGE}:arm32v7-${META_TAG} | ||
docker push ${LEGACYIMAGE}:arm64v8-${META_TAG} | ||
docker push ${LEGACYIMAGE}:latest | ||
docker push ${LEGACYIMAGE}:tftp | ||
docker push ${LEGACYIMAGE}:${META_TAG} | ||
docker push ${LEGACYIMAGE}:arm32v7-latest | ||
docker push ${LEGACYIMAGE}:arm64v8-latest | ||
docker push ${LEGACYIMAGE}:arm32v7-tftp | ||
docker push ${LEGACYIMAGE}:arm64v8-tftp | ||
done | ||
''' | ||
sh '''#! /bin/bash | ||
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do | ||
docker rmi \ | ||
${DELETEIMAGE}:amd64-${META_TAG} \ | ||
${DELETEIMAGE}:amd64-latest \ | ||
${DELETEIMAGE}:amd64-tftp \ | ||
${DELETEIMAGE}:arm32v7-${META_TAG} \ | ||
${DELETEIMAGE}:arm32v7-latest \ | ||
${DELETEIMAGE}:arm32v7-tftp \ | ||
${DELETEIMAGE}:arm64v8-${META_TAG} \ | ||
${DELETEIMAGE}:arm64v8-latest || : | ||
${DELETEIMAGE}:arm64v8-tftp || : | ||
done | ||
docker rmi \ | ||
lsiodev/buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} \ | ||
|
@@ -654,7 +661,7 @@ pipeline { | |
// If this is a public release tag it in the LS Github | ||
stage('Github-Tag-Push-Release') { | ||
when { | ||
branch "master" | ||
branch "tftp" | ||
expression { | ||
env.LS_RELEASE != env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER | ||
} | ||
|
@@ -666,17 +673,17 @@ pipeline { | |
sh '''curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/git/tags \ | ||
-d '{"tag":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ | ||
"object": "'${COMMIT_SHA}'",\ | ||
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to master",\ | ||
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to tftp",\ | ||
"type": "commit",\ | ||
"tagger": {"name": "LinuxServer Jenkins","email": "[email protected]","date": "'${GITHUB_DATE}'"}}' ''' | ||
echo "Pushing New release for Tag" | ||
sh '''#! /bin/bash | ||
echo "Updating to ${EXT_RELEASE_CLEAN}" > releasebody.json | ||
curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json | ||
echo '{"tag_name":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ | ||
"target_commitish": "master",\ | ||
"target_commitish": "tftp",\ | ||
"name": "'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ | ||
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**Remote Changes:**\\n\\n' > start | ||
printf '","draft": false,"prerelease": false}' >> releasebody.json | ||
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start | ||
printf '","draft": false,"prerelease": }' >> releasebody.json | ||
paste -d'\\0' start releasebody.json > releasebody.json.done | ||
curl -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/${LS_USER}/${LS_REPO}/releases -d @releasebody.json.done''' | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters