Commit 0bc78d08 authored by DJ Mountney's avatar DJ Mountney

Build cloud native images on tags

When on a tag, trigger a multi-project pipeline in the CNG repostiory.

Opting for a trigger rather than an addition to our release-tools
project for a few reasons:

- The Dockerfiles in the CNG image repo change infrequently, and as a result
I don't feel the need/overhead for stable branches in that repo at this time
- My intent with the CNG repo, is that once stable, the Dockerfiles
would actualy move to their component projects, to be versioned with the
code they are building
- It is likely that we will want to followup with a manually triggered package
for branches for devs, and possibly review apps, so it made sense to
build the CNG ci jobs to accept this sort of pipeline.
parent 09a387b5
...@@ -298,6 +298,25 @@ review-docs-cleanup: ...@@ -298,6 +298,25 @@ review-docs-cleanup:
script: script:
- ./trigger-build-docs cleanup - ./trigger-build-docs cleanup
##
# Trigger a docker image build in CNG (Cloud Native GitLab) repository
#
cloud-native-image:
image: ruby:2.4-alpine
before_script: []
stage: build
allow_failure: true
cache: {}
retry: 0
before_script:
- gem install gitlab --no-doc
- chmod 755 ./scripts/trigger-build-cloud-native
script:
- ./scripts/trigger-build-cloud-native
only:
- tags@gitlab-org/gitlab-ce
- tags@gitlab-org/gitlab-ee
# Retrieve knapsack and rspec_flaky reports # Retrieve knapsack and rspec_flaky reports
retrieve-tests-metadata: retrieve-tests-metadata:
<<: *tests-metadata-state <<: *tests-metadata-state
......
#!/usr/bin/env ruby
require 'gitlab'
#
# Configure credentials to be used with gitlab gem
#
Gitlab.configure do |config|
config.endpoint = 'https://gitlab.com/api/v4'
end
#
# The remote project
#
GITLAB_CNG_REPO = 'gitlab-org/build/CNG'.freeze
def ee?
ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md')
end
def read_file_version(filename)
raw_version = File.read(filename).strip
# if the version matches semver format, treat it as a tag and prepend `v`
if raw_version =~ Regexp.compile(/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/)
"v#{raw_version}"
else
raw_version
end
end
def params
params = {
'GITLAB_SHELL_VERSION' => read_file_version('GITLAB_SHELL_VERSION'),
'GITALY_VERSION' => read_file_version('GITALY_SERVER_VERSION'),
'TRIGGERED_USER' => ENV['GITLAB_USER_NAME'],
'TRIGGER_SOURCE' => "https://gitlab.com/gitlab-org/#{ENV['CI_PROJECT_NAME']}/-/jobs/#{ENV['CI_JOB_ID']}"
}
if ee?
params['EE_PIPELINE'] = 'true'
params['GITLAB_EE_VERSION'] = ENV['CI_COMMIT_REF_NAME']
else
params['CE_PIPELINE'] = 'true'
params['GITLAB_CE_VERSION'] = ENV['CI_COMMIT_REF_NAME']
end
params
end
#
# Trigger a pipeline
#
def trigger_pipeline
# Create the cross project pipeline using CI_JOB_TOKEN
pipeline = Gitlab.run_trigger(GITLAB_CNG_REPO, ENV['CI_JOB_TOKEN'], 'master', params)
puts "Triggered https://gitlab.com/#{GITLAB_CNG_REPO}/pipelines/#{pipeline.id}"
end
trigger_pipeline
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