Commit 02130af8 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'use-project-access-token-in-trigger-build' into 'master'

Use project access tokens for the multi-pipeline triggers

See merge request gitlab-org/gitlab!66548
parents 4ad862fa 571cc7af
...@@ -7,4 +7,4 @@ cloud-native-image: ...@@ -7,4 +7,4 @@ cloud-native-image:
GIT_DEPTH: "1" GIT_DEPTH: "1"
script: script:
- install_gitlab_gem - install_gitlab_gem
- CNG_PROJECT_PATH="gitlab-org/build/CNG" ./scripts/trigger-build cng - ./scripts/trigger-build cng
...@@ -27,12 +27,15 @@ review-build-cng: ...@@ -27,12 +27,15 @@ review-build-cng:
- .review:rules:review-build-cng - .review:rules:review-build-cng
image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7-alpine3.13 image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7-alpine3.13
stage: review-prepare stage: review-prepare
before_script:
- source ./scripts/utils.sh
- install_gitlab_gem
needs: needs:
- job: compile-production-assets - job: compile-production-assets
artifacts: false artifacts: false
variables:
CNG_PROJECT_ACCESS_TOKEN: "${CNG_MIRROR_PROJECT_ACCESS_TOKEN}" # "Multi-pipeline (from 'gitlab-org/gitlab' 'review-build-cng' job)" at https://gitlab.com/gitlab-org/build/CNG-mirror/-/settings/access_tokens
CNG_PROJECT_PATH: "gitlab-org/build/CNG-mirror"
before_script:
- source ./scripts/utils.sh
- install_gitlab_gem
script: script:
- ./scripts/trigger-build cng - ./scripts/trigger-build cng
......
...@@ -124,14 +124,19 @@ module Trigger ...@@ -124,14 +124,19 @@ module Trigger
end end
class Omnibus < Base class Omnibus < Base
def self.access_token
# Default to "Multi-pipeline (from 'gitlab-org/gitlab' 'package-and-qa' job)" at https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror/-/settings/access_tokens
ENV['OMNIBUS_GITLAB_PROJECT_ACCESS_TOKEN'] || super
end
private private
def downstream_project_path def downstream_project_path
ENV['OMNIBUS_PROJECT_PATH'] || 'gitlab-org/build/omnibus-gitlab-mirror' ENV.fetch('OMNIBUS_PROJECT_PATH', 'gitlab-org/build/omnibus-gitlab-mirror')
end end
def ref def ref
ENV['OMNIBUS_BRANCH'] || 'master' ENV.fetch('OMNIBUS_BRANCH', 'master')
end end
def extra_variables def extra_variables
...@@ -154,25 +159,21 @@ module Trigger ...@@ -154,25 +159,21 @@ module Trigger
end end
class CNG < Base class CNG < Base
def self.access_token
# Default to "Multi-pipeline (from 'gitlab-org/gitlab' 'cloud-native-image' job)" at https://gitlab.com/gitlab-org/build/CNG/-/settings/access_tokens
ENV['CNG_PROJECT_ACCESS_TOKEN'] || super
end
private private
def downstream_project_path def downstream_project_path
ENV['CNG_PROJECT_PATH'] || 'gitlab-org/build/CNG-mirror' ENV.fetch('CNG_PROJECT_PATH', 'gitlab-org/build/CNG')
end end
def ref def ref
default_ref = return ENV['CI_COMMIT_REF_NAME'] if ENV['CI_COMMIT_REF_NAME'] =~ /^[\d-]+-stable(-ee)?$/
if ENV['CI_COMMIT_REF_NAME'] =~ /^[\d-]+-stable(-ee)?$/
ENV['CI_COMMIT_REF_NAME']
else
'master'
end
ENV['CNG_BRANCH'] || default_ref
end
def trigger_token ENV.fetch('CNG_BRANCH', 'master')
ENV['CI_JOB_TOKEN']
end end
def extra_variables def extra_variables
...@@ -204,7 +205,8 @@ module Trigger ...@@ -204,7 +205,8 @@ module Trigger
class Docs < Base class Docs < Base
def self.access_token def self.access_token
ENV['DOCS_PROJECT_API_TOKEN'] # Default to "DOCS_PROJECT_API_TOKEN" at https://gitlab.com/gitlab-org/gitlab-docs/-/settings/access_tokens
ENV['DOCS_PROJECT_API_TOKEN'] || super
end end
SUCCESS_MESSAGE = <<~MSG SUCCESS_MESSAGE = <<~MSG
...@@ -253,11 +255,11 @@ module Trigger ...@@ -253,11 +255,11 @@ module Trigger
end end
def downstream_project_path def downstream_project_path
ENV['DOCS_PROJECT_PATH'] || 'gitlab-org/gitlab-docs' ENV.fetch('DOCS_PROJECT_PATH', 'gitlab-org/gitlab-docs')
end end
def ref def ref
ENV['DOCS_BRANCH'] || 'main' ENV.fetch('DOCS_BRANCH', 'main')
end end
# `gitlab-org/gitlab-docs` pipeline trigger "Triggered from gitlab-org/gitlab 'review-docs-deploy' job" # `gitlab-org/gitlab-docs` pipeline trigger "Triggered from gitlab-org/gitlab 'review-docs-deploy' job"
...@@ -349,7 +351,7 @@ module Trigger ...@@ -349,7 +351,7 @@ module Trigger
end end
def downstream_project_path def downstream_project_path
ENV['GITLABCOM_DATABASE_TESTING_PROJECT_PATH'] || 'gitlab-com/database-team/gitlab-com-database-testing' ENV.fetch('GITLABCOM_DATABASE_TESTING_PROJECT_PATH', 'gitlab-com/database-team/gitlab-com-database-testing')
end end
def extra_variables def extra_variables
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment