This repository has been archived by the owner on Feb 19, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from thelamer/prerelease
Adding Prerelease branch
- Loading branch information
Showing
7 changed files
with
75 additions
and
68 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
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 |
---|---|---|
|
@@ -16,9 +16,8 @@ pipeline { | |
GITHUB_TOKEN=credentials('498b4638-2d02-4ce5-832d-8a57d01d97ab') | ||
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0') | ||
GITLAB_NAMESPACE=credentials('gitlab-namespace-id') | ||
EXT_GIT_BRANCH = 'master' | ||
EXT_USER = 'popeen' | ||
EXT_REPO = 'Popeens-Subsonic' | ||
JSON_URL = 'https://api.github.com/repos/popeen/Popeens-Subsonic/releases' | ||
JSON_PATH = 'first(.[] | select(.prerelease==true)) | .tag_name' | ||
BUILD_VERSION_ARG = 'BOOKSONIC_RELEASE' | ||
LS_USER = 'linuxserver' | ||
LS_REPO = 'docker-booksonic' | ||
|
@@ -44,7 +43,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}':prerelease 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' ''', | ||
|
@@ -101,21 +100,14 @@ pipeline { | |
/* ######################## | ||
External Release Tagging | ||
######################## */ | ||
// If this is a stable github release use the latest endpoint from github to determine the ext tag | ||
stage("Set ENV github_stable"){ | ||
// If this is a custom json endpoint parse the return to get external tag | ||
stage("Set ENV custom_json"){ | ||
steps{ | ||
script{ | ||
env.EXT_RELEASE = sh( | ||
script: '''curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq -r '. | .tag_name' ''', | ||
script: '''curl -s ${JSON_URL} | jq -r ". | ${JSON_PATH}" ''', | ||
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 | ||
env.RELEASE_LINK = env.JSON_URL | ||
} | ||
} | ||
} | ||
|
@@ -129,10 +121,10 @@ pipeline { | |
} | ||
} | ||
} | ||
// If this is a master build use live docker endpoints | ||
// If this is a prerelease build use live docker endpoints | ||
stage("Set ENV live build"){ | ||
when { | ||
branch "master" | ||
branch "prerelease" | ||
environment name: 'CHANGE_ID', value: '' | ||
} | ||
steps { | ||
|
@@ -153,7 +145,7 @@ pipeline { | |
// If this is a dev build use dev docker endpoints | ||
stage("Set ENV dev build"){ | ||
when { | ||
not {branch "master"} | ||
not {branch "prerelease"} | ||
environment name: 'CHANGE_ID', value: '' | ||
} | ||
steps { | ||
|
@@ -226,7 +218,7 @@ pipeline { | |
// Use helper containers to render templated files | ||
stage('Update-Templates') { | ||
when { | ||
branch "master" | ||
branch "prerelease" | ||
environment name: 'CHANGE_ID', value: '' | ||
expression { | ||
env.CONTAINER_NAME != null | ||
|
@@ -237,15 +229,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=prerelease -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 prerelease | ||
cd ${TEMPDIR}/docker-${CONTAINER_NAME} | ||
mkdir -p ${TEMPDIR}/repo/${LS_REPO}/.github | ||
cp --parents ${TEMPLATED_FILES} ${TEMPDIR}/repo/${LS_REPO}/ | ||
|
@@ -277,7 +269,7 @@ pipeline { | |
// Exit the build if the Templated files were just updated | ||
stage('Template-exit') { | ||
when { | ||
branch "master" | ||
branch "prerelease" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'FILES_UPDATED', value: 'true' | ||
expression { | ||
|
@@ -396,7 +388,7 @@ pipeline { | |
// Take the image we just built and dump package versions for comparison | ||
stage('Update-packages') { | ||
when { | ||
branch "master" | ||
branch "prerelease" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'EXIT_STATUS', value: '' | ||
} | ||
|
@@ -424,7 +416,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 prerelease | ||
cp ${TEMPDIR}/package_versions.txt ${TEMPDIR}/${LS_REPO}/ | ||
cd ${TEMPDIR}/${LS_REPO}/ | ||
wait | ||
|
@@ -448,7 +440,7 @@ pipeline { | |
// Exit the build if the package file was just updated | ||
stage('PACKAGE-exit') { | ||
when { | ||
branch "master" | ||
branch "prerelease" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'PACKAGE_UPDATED', value: 'true' | ||
environment name: 'EXIT_STATUS', value: '' | ||
|
@@ -462,7 +454,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 "prerelease" | ||
environment name: 'CHANGE_ID', value: '' | ||
environment name: 'PACKAGE_UPDATED', value: 'false' | ||
environment name: 'EXIT_STATUS', value: '' | ||
|
@@ -557,14 +549,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}:prerelease | ||
docker push ${PUSHIMAGE}:prerelease | ||
docker push ${PUSHIMAGE}:${META_TAG} | ||
done | ||
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "{GITLABIMAGE}" "${IMAGE}"; do | ||
docker rmi \ | ||
${DELETEIMAGE}:${META_TAG} \ | ||
${DELETEIMAGE}:latest || : | ||
${DELETEIMAGE}:prerelease || : | ||
done | ||
''' | ||
} | ||
|
@@ -607,52 +599,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-prerelease | ||
docker tag ${MANIFESTIMAGE}:arm32v7-${META_TAG} ${MANIFESTIMAGE}:arm32v7-prerelease | ||
docker tag ${MANIFESTIMAGE}:arm64v8-${META_TAG} ${MANIFESTIMAGE}:arm64v8-prerelease | ||
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-prerelease | ||
docker push ${MANIFESTIMAGE}:arm32v7-prerelease | ||
docker push ${MANIFESTIMAGE}:arm64v8-prerelease | ||
docker manifest push --purge ${MANIFESTIMAGE}:prerelease || : | ||
docker manifest create ${MANIFESTIMAGE}:prerelease ${MANIFESTIMAGE}:amd64-prerelease ${MANIFESTIMAGE}:arm32v7-prerelease ${MANIFESTIMAGE}:arm64v8-prerelease | ||
docker manifest annotate ${MANIFESTIMAGE}:prerelease ${MANIFESTIMAGE}:arm32v7-prerelease --os linux --arch arm | ||
docker manifest annotate ${MANIFESTIMAGE}:prerelease ${MANIFESTIMAGE}:arm64v8-prerelease --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}:prerelease | ||
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}:prerelease | ||
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-prerelease | ||
docker tag ${LEGACYIMAGE}:arm64v8-${META_TAG} ${LEGACYIMAGE}:arm64v8-prerelease | ||
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}:prerelease | ||
docker push ${LEGACYIMAGE}:${META_TAG} | ||
docker push ${LEGACYIMAGE}:arm32v7-latest | ||
docker push ${LEGACYIMAGE}:arm64v8-latest | ||
docker push ${LEGACYIMAGE}:arm32v7-prerelease | ||
docker push ${LEGACYIMAGE}:arm64v8-prerelease | ||
done | ||
''' | ||
sh '''#! /bin/bash | ||
for DELETEIMAGE in "${QUAYIMAGE}" "${GITHUBIMAGE}" "${GITLABIMAGE}" "${IMAGE}"; do | ||
docker rmi \ | ||
${DELETEIMAGE}:amd64-${META_TAG} \ | ||
${DELETEIMAGE}:amd64-latest \ | ||
${DELETEIMAGE}:amd64-prerelease \ | ||
${DELETEIMAGE}:arm32v7-${META_TAG} \ | ||
${DELETEIMAGE}:arm32v7-latest \ | ||
${DELETEIMAGE}:arm32v7-prerelease \ | ||
${DELETEIMAGE}:arm64v8-${META_TAG} \ | ||
${DELETEIMAGE}:arm64v8-latest || : | ||
${DELETEIMAGE}:arm64v8-prerelease || : | ||
done | ||
docker rmi \ | ||
lsiodev/buildcache:arm32v7-${COMMIT_SHA}-${BUILD_NUMBER} \ | ||
|
@@ -664,7 +656,7 @@ pipeline { | |
// If this is a public release tag it in the LS Github | ||
stage('Github-Tag-Push-Release') { | ||
when { | ||
branch "master" | ||
branch "prerelease" | ||
expression { | ||
env.LS_RELEASE != env.EXT_RELEASE_CLEAN + '-ls' + env.LS_TAG_NUMBER | ||
} | ||
|
@@ -676,17 +668,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 prerelease",\ | ||
"type": "commit",\ | ||
"tagger": {"name": "LinuxServer Jenkins","email": "[email protected]","date": "'${GITHUB_DATE}'"}}' ''' | ||
echo "Pushing New release for Tag" | ||
sh '''#! /bin/bash | ||
curl -s https://api.github.com/repos/${EXT_USER}/${EXT_REPO}/releases/latest | jq '. |.body' | sed 's:^.\\(.*\\).$:\\1:' > releasebody.json | ||
echo "Data change at JSON endpoint ${JSON_URL}" > releasebody.json | ||
echo '{"tag_name":"'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ | ||
"target_commitish": "master",\ | ||
"target_commitish": "prerelease",\ | ||
"name": "'${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}'",\ | ||
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**'${EXT_REPO}' Changes:**\\n\\n' > start | ||
printf '","draft": false,"prerelease": false}' >> releasebody.json | ||
"body": "**LinuxServer Changes:**\\n\\n'${LS_RELEASE_NOTES}'\\n**Remote Changes:**\\n\\n' > start | ||
printf '","draft": false,"prerelease": true}' >> 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