Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
dd72134e
Commit
dd72134e
authored
Jun 14, 2018
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the trigger-build script into one location to serve both omnibus and cloud-native triggers.
parent
434efdac
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
184 additions
and
64 deletions
+184
-64
.gitlab-ci.yml
.gitlab-ci.yml
+2
-2
.rubocop_todo.yml
.rubocop_todo.yml
+1
-1
scripts/trigger-build
scripts/trigger-build
+181
-0
scripts/trigger-build-cloud-native
scripts/trigger-build-cloud-native
+0
-61
No files found.
.gitlab-ci.yml
View file @
dd72134e
...
@@ -264,10 +264,10 @@ package-and-qa:
...
@@ -264,10 +264,10 @@ package-and-qa:
<<
:
*single-script-job
<<
:
*single-script-job
variables
:
variables
:
<<
:
*single-script-job-variables
<<
:
*single-script-job-variables
SCRIPT_NAME
:
trigger-build
-omnibus
SCRIPT_NAME
:
trigger-build
retry
:
0
retry
:
0
script
:
script
:
-
./$SCRIPT_NAME
-
./$SCRIPT_NAME
omnibus
when
:
manual
when
:
manual
only
:
only
:
-
//@gitlab-org/gitlab-ce
-
//@gitlab-org/gitlab-ce
...
...
.rubocop_todo.yml
View file @
dd72134e
...
@@ -487,7 +487,7 @@ Style/EmptyLiteral:
...
@@ -487,7 +487,7 @@ Style/EmptyLiteral:
-
'
lib/gitlab/fogbugz_import/importer.rb'
-
'
lib/gitlab/fogbugz_import/importer.rb'
-
'
lib/gitlab/git/diff_collection.rb'
-
'
lib/gitlab/git/diff_collection.rb'
-
'
lib/gitlab/gitaly_client.rb'
-
'
lib/gitlab/gitaly_client.rb'
-
'
scripts/trigger-build
-omnibus
'
-
'
scripts/trigger-build'
-
'
spec/features/merge_requests/versions_spec.rb'
-
'
spec/features/merge_requests/versions_spec.rb'
-
'
spec/helpers/merge_requests_helper_spec.rb'
-
'
spec/helpers/merge_requests_helper_spec.rb'
-
'
spec/lib/gitlab/request_context_spec.rb'
-
'
spec/lib/gitlab/request_context_spec.rb'
...
...
scripts/trigger-build
-omnibus
→
scripts/trigger-build
View file @
dd72134e
...
@@ -4,44 +4,44 @@ require 'net/http'
...
@@ -4,44 +4,44 @@ require 'net/http'
require
'json'
require
'json'
require
'cgi'
require
'cgi'
module
Omnibus
module
Trigger
PROJECT_PATH
=
'gitlab-org/omnibus-gitlab'
.
freeze
OMNIBUS_PROJECT_PATH
=
'gitlab-org/omnibus-gitlab'
.
freeze
CNG_PROJECT_PATH
=
'gitlab-org/build/CNG'
.
freeze
class
Trigger
TOKEN
=
ENV
[
'BUILD_TRIGGER_TOKEN'
]
TOKEN
=
ENV
[
'BUILD_TRIGGER_TOKEN'
]
TRIGGERER
=
ENV
[
'CI_PROJECT_NAME'
]
def
self
.
ee?
ENV
[
'CI_PROJECT_NAME'
]
==
'gitlab-ee'
||
File
.
exist?
(
'CHANGELOG-EE.md'
)
end
class
Omnibus
def
initialize
def
initialize
@uri
=
URI
(
"https://gitlab.com/api/v4/projects/
#{
CGI
.
escape
(
Omnibus
::
PROJECT_PATH
)
}
/trigger/pipeline"
)
@uri
=
URI
(
"https://gitlab.com/api/v4/projects/
#{
CGI
.
escape
(
Trigger
::
OMNIBUS_
PROJECT_PATH
)
}
/trigger/pipeline"
)
@params
=
env_params
.
merge
(
file_params
).
merge
(
token:
TOKEN
)
@params
=
env_params
.
merge
(
file_params
).
merge
(
token:
T
rigger
::
T
OKEN
)
end
end
def
invoke!
def
invoke!
res
=
Net
::
HTTP
.
post_form
(
@uri
,
@params
)
res
=
Net
::
HTTP
.
post_form
(
@uri
,
@params
)
id
=
JSON
.
parse
(
res
.
body
)[
'id'
]
id
=
JSON
.
parse
(
res
.
body
)[
'id'
]
project
=
Trigger
::
OMNIBUS_PROJECT_PATH
if
id
if
id
puts
"Triggered https://gitlab.com/
#{
Omnibus
::
PROJECT_PATH
}
/pipelines/
#{
id
}
"
puts
"Triggered https://gitlab.com/
#{
project
}
/pipelines/
#{
id
}
"
puts
"Waiting for downstream pipeline status"
puts
"Waiting for downstream pipeline status"
else
else
raise
"Trigger failed! The response from the trigger is:
#{
res
.
body
}
"
raise
"Trigger failed! The response from the trigger is:
#{
res
.
body
}
"
end
end
Omnibus
::
Pipeline
.
new
(
id
)
Trigger
::
Pipeline
.
new
(
project
,
id
)
end
end
private
private
def
ee?
TRIGGERER
==
'gitlab-ee'
||
File
.
exist?
(
'CHANGELOG-EE.md'
)
end
def
env_params
def
env_params
{
{
"ref"
=>
ENV
[
"OMNIBUS_BRANCH"
]
||
"master"
,
"ref"
=>
ENV
[
"OMNIBUS_BRANCH"
]
||
"master"
,
"variables[GITLAB_VERSION]"
=>
ENV
[
"CI_COMMIT_SHA"
],
"variables[GITLAB_VERSION]"
=>
ENV
[
"CI_COMMIT_SHA"
],
"variables[ALTERNATIVE_SOURCES]"
=>
true
,
"variables[ALTERNATIVE_SOURCES]"
=>
true
,
"variables[ee]"
=>
ee?
?
'true'
:
'false'
,
"variables[ee]"
=>
Trigger
.
ee?
?
'true'
:
'false'
,
"variables[TRIGGERED_USER]"
=>
ENV
[
"GITLAB_USER_NAME"
],
"variables[TRIGGERED_USER]"
=>
ENV
[
"GITLAB_USER_NAME"
],
"variables[TRIGGER_SOURCE]"
=>
"https://gitlab.com/gitlab-org/
#{
ENV
[
'CI_PROJECT_NAME'
]
}
/-/jobs/
#{
ENV
[
'CI_JOB_ID'
]
}
"
"variables[TRIGGER_SOURCE]"
=>
"https://gitlab.com/gitlab-org/
#{
ENV
[
'CI_PROJECT_NAME'
]
}
/-/jobs/
#{
ENV
[
'CI_JOB_ID'
]
}
"
}
}
...
@@ -56,13 +56,77 @@ module Omnibus
...
@@ -56,13 +56,77 @@ module Omnibus
end
end
end
end
class
CNG
def
initialize
@uri
=
URI
(
"https://gitlab.com/api/v4/projects/
#{
CGI
.
escape
(
Trigger
::
CNG_PROJECT_PATH
)
}
/trigger/pipeline"
)
@ref_name
=
ENV
[
'CI_COMMIT_REF_NAME'
]
@username
=
ENV
[
'GITLAB_USER_NAME'
]
@project_name
=
ENV
[
'CI_PROJECT_NAME'
]
@job_id
=
ENV
[
'CI_JOB_ID'
]
@params
=
env_params
.
merge
(
file_params
).
merge
(
token:
Trigger
::
TOKEN
)
end
#
# Trigger a pipeline
#
def
invoke!
res
=
Net
::
HTTP
.
post_form
(
@uri
,
@params
)
id
=
JSON
.
parse
(
res
.
body
)[
'id'
]
project
=
Trigger
::
CNG_PROJECT_PATH
if
id
puts
"Triggered https://gitlab.com/
#{
project
}
/pipelines/
#{
id
}
"
puts
"Waiting for downstream pipeline status"
else
raise
"Trigger failed! The response from the trigger is:
#{
res
.
body
}
"
end
Trigger
::
Pipeline
.
new
(
project
,
id
)
end
private
def
env_params
params
=
{
"ref"
=>
ENV
[
"CNG_BRANCH"
]
||
"master"
,
"variables[TRIGGERED_USER]"
=>
@username
,
"variables[TRIGGER_SOURCE]"
=>
"https://gitlab.com/gitlab-org/
#{
@project_name
}
/-/jobs/
#{
@job_id
}
"
}
if
Trigger
.
ee?
params
[
"variables[GITLAB_EE_VERSION]"
]
=
@ref_name
params
[
"variables[EE_PIPELINE]"
]
=
'true'
else
params
[
"variables[GITLAB_CE_VERSION]"
]
=
@ref_name
params
[
"variables[CE_PIPELINE]"
]
=
'true'
end
params
end
# Read version files from all components
def
file_params
Dir
.
glob
(
"*_VERSION"
).
each_with_object
({})
do
|
version_file
,
params
|
raw_version
=
File
.
read
(
version_file
).
strip
# if the version matches semver format, treat it as a tag and prepend `v`
version
=
if
raw_version
=~
Regexp
.
compile
(
/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/
)
"v
#{
raw_version
}
"
else
raw_version
end
params
[
"variables[
#{
version_file
}
]"
]
=
version
end
end
end
class
Pipeline
class
Pipeline
INTERVAL
=
60
# seconds
INTERVAL
=
60
# seconds
MAX_DURATION
=
3600
*
3
# 3 hours
MAX_DURATION
=
3600
*
3
# 3 hours
def
initialize
(
id
)
def
initialize
(
project
,
id
)
@start
=
Time
.
now
.
to_i
@start
=
Time
.
now
.
to_i
@uri
=
URI
(
"https://gitlab.com/api/v4/projects/
#{
CGI
.
escape
(
Omnibus
::
PROJECT_PATH
)
}
/pipelines/
#{
id
}
"
)
@uri
=
URI
(
"https://gitlab.com/api/v4/projects/
#{
CGI
.
escape
(
project
)
}
/pipelines/
#{
id
}
"
)
end
end
def
wait!
def
wait!
...
@@ -74,10 +138,10 @@ module Omnibus
...
@@ -74,10 +138,10 @@ module Omnibus
print
"."
print
"."
sleep
INTERVAL
sleep
INTERVAL
when
:success
when
:success
puts
"
Omnibus p
ipeline succeeded in
#{
duration
}
minutes!"
puts
"
P
ipeline succeeded in
#{
duration
}
minutes!"
break
break
else
else
raise
"
Omnibus p
ipeline did not succeed!"
raise
"
P
ipeline did not succeed!"
end
end
STDOUT
.
flush
STDOUT
.
flush
...
@@ -105,4 +169,13 @@ module Omnibus
...
@@ -105,4 +169,13 @@ module Omnibus
end
end
end
end
Omnibus
::
Trigger
.
new
.
invoke!
.
wait!
case
ARGV
[
0
]
when
'omnibus'
Trigger
::
Omnibus
.
new
.
invoke!
.
wait!
when
'cng'
Trigger
::
CNG
.
new
.
invoke!
.
wait!
else
puts
"Please provide a valid option:
omnibus - Triggers a pipeline that builds the omnibus-gitlab package
cng - Triggers a pipeline that builds images used by the GitLab helm chart"
end
scripts/trigger-build-cloud-native
deleted
100755 → 0
View file @
434efdac
#!/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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment