From bb0ce2c1ef8ce630df512ce904e8b2b30d4742e3 Mon Sep 17 00:00:00 2001 From: aptalca <541623+aptalca@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:06:11 -0400 Subject: [PATCH] Add step for marking quay.io repos as public --- Jenkinsfile | 15 +++++++++++++++ roles/generate-jenkins/templates/Jenkinsfile.j2 | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 7b6ce6d..51e5761 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,6 +17,7 @@ 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') BUILD_VERSION_ARG='BUILDER_VERSION' LS_USER='linuxserver' LS_REPO='docker-jenkins-builder' @@ -39,6 +40,7 @@ pipeline { // 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 @@ -480,6 +482,19 @@ pipeline { -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" ''' } } + /* ####################### + Quay.io Repo Visibility + ####################### */ + // Mark this repo on Quay.io as public + stage("Quay.io Repo Visibility"){ + when { + environment name: 'EXIT_STATUS', value: '' + } + steps{ + 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"}' ||: ''' + } + } /* ############### Build Container ############### */ diff --git a/roles/generate-jenkins/templates/Jenkinsfile.j2 b/roles/generate-jenkins/templates/Jenkinsfile.j2 index 5e093a4..9db1e93 100644 --- a/roles/generate-jenkins/templates/Jenkinsfile.j2 +++ b/roles/generate-jenkins/templates/Jenkinsfile.j2 @@ -17,6 +17,7 @@ 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') {% for repo_var in repo_vars %} {{ repo_var }} {% endfor %} @@ -710,6 +711,19 @@ pipeline { -d "mirror=true&import_url=https://github.com/linuxserver/${LS_REPO}.git" ''' }{{ ' ' }} } + /* ####################### + Quay.io Repo Visibility + ####################### */ + // Mark this repo on Quay.io as public + stage("Quay.io Repo Visibility"){ + when { + environment name: 'EXIT_STATUS', value: '' + } + steps{ + 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"}' ||: ''' + }{{ ' ' }} + } /* ############### Build Container ############### */