Welcome to mirror list, hosted at ThFree Co, Russian Federation.

trigger-build-cloud-native « scripts - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b6ca75a588d245d7733887f17f518e41594f781f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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