Skip to content

Commit

Permalink
Bot Updating Templated Files
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxServer-CI committed Aug 12, 2024
1 parent a675149 commit 9681eaa
Showing 1 changed file with 8 additions and 52 deletions.
60 changes: 8 additions & 52 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pipeline {
GITLAB_TOKEN=credentials('b6f0f1dd-6952-4cf6-95d1-9c06380283f0')
GITLAB_NAMESPACE=credentials('gitlab-namespace-id')
DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat')
QUAYIO_API_TOKEN=credentials('quayio-repo-api-token')
GIT_SIGNING_KEY=credentials('484fbca6-9a4f-455e-b9e3-97ac98785f5f')
EXT_GIT_BRANCH = 'main'
EXT_USER = 'bakito'
EXT_REPO = 'adguardhome-sync'
Expand All @@ -41,25 +39,9 @@ pipeline {
CI_WEBPATH=''
}
stages {
stage("Set git config"){
steps{
sh '''#!/bin/bash
cat ${GIT_SIGNING_KEY} > /config/.ssh/id_sign
chmod 600 /config/.ssh/id_sign
ssh-keygen -y -f /config/.ssh/id_sign > /config/.ssh/id_sign.pub
echo "Using $(ssh-keygen -lf /config/.ssh/id_sign) to sign commits"
git config --global gpg.format ssh
git config --global user.signingkey /config/.ssh/id_sign
git config --global commit.gpgsign true
git config --global user.name LinuxServer-CI
git config --global user.email ci@linuxserver.io
'''
}
}
// Setup all the basic environment variables needed for the build
stage("Set ENV Variables base"){
steps{
echo "Running on node: ${NODE_NAME}"
sh '''#! /bin/bash
containers=$(docker ps -aq)
if [[ -n "${containers}" ]]; then
Expand Down Expand Up @@ -504,10 +486,10 @@ pipeline {
}
}
/* #######################
GitLab Mirroring and Quay.io Repo Visibility
GitLab Mirroring
####################### */
// Ping into Gitlab to mirror this repo and have a registry endpoint & mark this repo on Quay.io as public
stage("GitLab Mirror and Quay.io Visibility"){
// Ping into Gitlab to mirror this repo and have a registry endpoint
stage("GitLab Mirror"){
when {
environment name: 'EXIT_STATUS', value: ''
}
Expand All @@ -523,8 +505,6 @@ pipeline {
"visibility":"public"}' '''
sh '''curl -H "Private-Token: ${GITLAB_TOKEN}" -X PUT "https://gitlab.com/api/v4/projects/Linuxserver.io%2F${LS_REPO}" \
-d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" '''
sh '''curl -H "Content-Type: application/json" -H "Authorization: Bearer ${QUAYIO_API_TOKEN}" -X POST "https://quay.io/api/v1/repository${QUAYIMAGE/quay.io/}/changevisibility" \
-d '{"visibility":"public"}' ||: '''
}
}
/* ###############
Expand Down Expand Up @@ -619,7 +599,7 @@ pipeline {
--provenance=false --sbom=false \
--build-arg ${BUILD_VERSION_ARG}=${EXT_RELEASE} --build-arg VERSION=\"${VERSION_TAG}\" --build-arg BUILD_DATE=${GITHUB_DATE} ."
sh "docker tag ${IMAGE}:arm64v8-${META_TAG} ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
retry_backoff(5,5) {
retry(5) {
sh "docker push ghcr.io/linuxserver/lsiodev-buildcache:arm64v8-${COMMIT_SHA}-${BUILD_NUMBER}"
}
sh '''#! /bin/bash
Expand Down Expand Up @@ -775,7 +755,7 @@ pipeline {
passwordVariable: 'QUAYPASS'
]
]) {
retry_backoff(5,5) {
retry(5) {
sh '''#! /bin/bash
set -e
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
Expand All @@ -793,7 +773,7 @@ pipeline {
docker push ${PUSHIMAGE}:${META_TAG}
docker push ${PUSHIMAGE}:${EXT_RELEASE_TAG}
if [ -n "${SEMVER}" ]; then
docker push ${PUSHIMAGE}:${SEMVER}
docker push ${PUSHIMAGE}:${SEMVER}
fi
done
'''
Expand All @@ -816,7 +796,7 @@ pipeline {
passwordVariable: 'QUAYPASS'
]
]) {
retry_backoff(5,5) {
retry(5) {
sh '''#! /bin/bash
set -e
echo $DOCKERHUB_TOKEN | docker login -u linuxserverci --password-stdin
Expand Down Expand Up @@ -879,7 +859,7 @@ pipeline {
"object": "'${COMMIT_SHA}'",\
"message": "Tagging Release '${EXT_RELEASE_CLEAN}'-ls'${LS_TAG_NUMBER}' to main",\
"type": "commit",\
"tagger": {"name": "LinuxServer-CI","email": "ci@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
"tagger": {"name": "LinuxServer Jenkins","email": "jenkins@linuxserver.io","date": "'${GITHUB_DATE}'"}}' '''
echo "Pushing New release for Tag"
sh '''#! /bin/bash
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
Expand Down Expand Up @@ -1011,13 +991,6 @@ EOF
###################### */
post {
always {
sh '''#!/bin/bash
rm -rf /config/.ssh/id_sign
rm -rf /config/.ssh/id_sign.pub
git config --global --unset gpg.format
git config --global --unset user.signingkey
git config --global --unset commit.gpgsign
'''
script{
if (env.EXIT_STATUS == "ABORTED"){
sh 'echo "build aborted"'
Expand Down Expand Up @@ -1047,20 +1020,3 @@ EOF
}
}
}

def retry_backoff(int max_attempts, int power_base, Closure c) {
int n = 0
while (n < max_attempts) {
try {
c()
return
} catch (err) {
if ((n + 1) >= max_attempts) {
throw err
}
sleep(power_base ** n)
n++
}
}
return
}

0 comments on commit 9681eaa

Please sign in to comment.