summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-05-21 10:51:27 +0000
committerRémy Coutable <remy@rymai.me>2018-05-21 10:51:27 +0000
commitd7b3eb3de43e1c12fc8475adf966577f469a1adf (patch)
tree3b28b5f952abd1e69c5a615d3fd8dcef2b60cf62
parent8e38ed8c3700df04a1fc9a006a702d5777215a80 (diff)
parent1fb431c6acfa0bdc578a6488147ed5f28aaa96c3 (diff)
downloadgitlab-ce-d7b3eb3de43e1c12fc8475adf966577f469a1adf.tar.gz
Merge branch 'trigger-cng-image' into 'master'
Build cloud native images on tags See merge request gitlab-org/gitlab-ce!19025
-rw-r--r--.gitlab-ci.yml18
-rwxr-xr-xscripts/trigger-build-cloud-native61
2 files changed, 79 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 84d8e69b84e..c0c1f3c8ec3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -298,6 +298,24 @@ review-docs-cleanup:
script:
- ./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: {}
+ before_script:
+ - gem install gitlab --no-rdoc --no-ri
+ - 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-tests-metadata:
<<: *tests-metadata-state
diff --git a/scripts/trigger-build-cloud-native b/scripts/trigger-build-cloud-native
new file mode 100755
index 00000000000..b6ca75a588d
--- /dev/null
+++ b/scripts/trigger-build-cloud-native
@@ -0,0 +1,61 @@
+#!/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