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
906b79c4
Commit
906b79c4
authored
May 11, 2021
by
Jaime Martinez
Committed by
Shinya Maeda
May 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add asset links to release CLI commands
parent
c6059630
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
6 deletions
+29
-6
changelogs/unreleased/271454-add-links-to-release-ci-yaml.yml
...gelogs/unreleased/271454-add-links-to-release-ci-yaml.yml
+5
-0
lib/gitlab/ci/build/releaser.rb
lib/gitlab/ci/build/releaser.rb
+10
-1
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+2
-1
spec/lib/gitlab/ci/build/releaser_spec.rb
spec/lib/gitlab/ci/build/releaser_spec.rb
+10
-2
spec/lib/gitlab/ci/build/step_spec.rb
spec/lib/gitlab/ci/build/step_spec.rb
+1
-1
spec/requests/api/ci/runner/jobs_request_post_spec.rb
spec/requests/api/ci/runner/jobs_request_post_spec.rb
+1
-1
No files found.
changelogs/unreleased/271454-add-links-to-release-ci-yaml.yml
0 → 100644
View file @
906b79c4
---
title
:
Add asset links to release keyword
merge_request
:
60896
author
:
type
:
added
lib/gitlab/ci/build/releaser.rb
View file @
906b79c4
...
...
@@ -18,8 +18,9 @@ module Gitlab
command
=
BASE_COMMAND
.
dup
single_flags
.
each
{
|
k
,
v
|
command
.
concat
(
" --
#{
k
.
to_s
.
dasherize
}
\"
#{
v
}
\"
"
)
}
array_commands
.
each
{
|
k
,
v
|
v
.
each
{
|
elem
|
command
.
concat
(
" --
#{
k
.
to_s
.
singularize
.
dasherize
}
\"
#{
elem
}
\"
"
)
}
}
asset_links
.
each
{
|
link
|
command
.
concat
(
" --assets-link
#{
stringified_json
(
link
)
}
"
)
}
[
command
]
[
command
.
freeze
]
end
private
...
...
@@ -31,6 +32,14 @@ module Gitlab
def
array_commands
config
.
slice
(
*
ARRAY_FLAGS
)
end
def
asset_links
config
.
dig
(
:assets
,
:links
)
||
[]
end
def
stringified_json
(
object
)
"
#{
object
.
to_json
.
to_json
}
"
end
end
end
end
...
...
spec/factories/ci/builds.rb
View file @
906b79c4
...
...
@@ -431,7 +431,8 @@ FactoryBot.define do
name:
'Release $CI_COMMIT_SHA'
,
description:
'Created using the release-cli $EXTRA_DESCRIPTION'
,
tag_name:
'release-$CI_COMMIT_SHA'
,
ref:
'$CI_COMMIT_SHA'
ref:
'$CI_COMMIT_SHA'
,
assets:
{
links:
[{
name:
'asset1'
,
url:
'https://example.com/assets/1'
}]
}
}
}
end
...
...
spec/lib/gitlab/ci/build/releaser_spec.rb
View file @
906b79c4
...
...
@@ -15,18 +15,25 @@ RSpec.describe Gitlab::Ci::Build::Releaser do
tag_name:
'release-$CI_COMMIT_SHA'
,
ref:
'$CI_COMMIT_SHA'
,
milestones:
%w[m1 m2 m3]
,
released_at:
'2020-07-15T08:00:00Z'
released_at:
'2020-07-15T08:00:00Z'
,
assets:
{
links:
[
{
name:
'asset1'
,
url:
'https://example.com/assets/1'
,
link_type:
'other'
,
filepath:
'/pretty/asset/1'
},
{
name:
'asset2'
,
url:
'https://example.com/assets/2'
}
]
}
}
}
end
it
'generates the script'
do
expect
(
subject
).
to
eq
([
'release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA" --released-at "2020-07-15T08:00:00Z" --milestone "m1" --milestone "m2" --milestone "m3"'
])
expect
(
subject
).
to
eq
([
'release-cli create --name "Release $CI_COMMIT_SHA" --description "Created using the release-cli $EXTRA_DESCRIPTION" --tag-name "release-$CI_COMMIT_SHA" --ref "$CI_COMMIT_SHA" --released-at "2020-07-15T08:00:00Z" --milestone "m1" --milestone "m2" --milestone "m3"
--assets-link "{\"name\":\"asset1\",\"url\":\"https://example.com/assets/1\",\"link_type\":\"other\",\"filepath\":\"/pretty/asset/1\"}" --assets-link "{\"name\":\"asset2\",\"url\":\"https://example.com/assets/2\"}"
'
])
end
end
context
'individual nodes'
do
using
RSpec
::
Parameterized
::
TableSyntax
links
=
{
links:
[{
name:
'asset1'
,
url:
'https://example.com/assets/1'
,
link_type:
'other'
,
filepath:
'/pretty/asset/1'
}]
}
where
(
:node_name
,
:node_value
,
:result
)
do
:name
|
'Release $CI_COMMIT_SHA'
|
'release-cli create --name "Release $CI_COMMIT_SHA"'
...
...
@@ -35,6 +42,7 @@ RSpec.describe Gitlab::Ci::Build::Releaser do
:ref
|
'$CI_COMMIT_SHA'
|
'release-cli create --ref "$CI_COMMIT_SHA"'
:milestones
|
%w[m1 m2 m3]
|
'release-cli create --milestone "m1" --milestone "m2" --milestone "m3"'
:released_at
|
'2020-07-15T08:00:00Z'
|
'release-cli create --released-at "2020-07-15T08:00:00Z"'
:assets
|
links
|
"release-cli create --assets-link
#{
links
[
:links
][
0
].
to_json
.
to_json
}
"
end
with_them
do
...
...
spec/lib/gitlab/ci/build/step_spec.rb
View file @
906b79c4
...
...
@@ -62,7 +62,7 @@ RSpec.describe Gitlab::Ci::Build::Step do
let
(
:job
)
{
create
(
:ci_build
,
:release_options
)
}
it
'returns the release-cli command line'
do
expect
(
subject
.
script
).
to
eq
([
"release-cli create --name
\"
Release $CI_COMMIT_SHA
\"
--description
\"
Created using the release-cli $EXTRA_DESCRIPTION
\"
--tag-name
\"
release-$CI_COMMIT_SHA
\"
--ref
\"
$CI_COMMIT_SHA
\"
"
])
expect
(
subject
.
script
).
to
eq
([
"release-cli create --name
\"
Release $CI_COMMIT_SHA
\"
--description
\"
Created using the release-cli $EXTRA_DESCRIPTION
\"
--tag-name
\"
release-$CI_COMMIT_SHA
\"
--ref
\"
$CI_COMMIT_SHA
\"
--assets-link
\"
{
\\\"
name
\\\"
:
\\\"
asset1
\\\"
,
\\\"
url
\\\"
:
\\\"
https://example.com/assets/1
\\\"
}
\"
"
])
end
end
...
...
spec/requests/api/ci/runner/jobs_request_post_spec.rb
View file @
906b79c4
...
...
@@ -378,7 +378,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
{
"name"
=>
"release"
,
"script"
=>
[
"release-cli create --name
\"
Release $CI_COMMIT_SHA
\"
--description
\"
Created using the release-cli $EXTRA_DESCRIPTION
\"
--tag-name
\"
release-$CI_COMMIT_SHA
\"
--ref
\"
$CI_COMMIT_SHA
\"
"
],
[
"release-cli create --name
\"
Release $CI_COMMIT_SHA
\"
--description
\"
Created using the release-cli $EXTRA_DESCRIPTION
\"
--tag-name
\"
release-$CI_COMMIT_SHA
\"
--ref
\"
$CI_COMMIT_SHA
\"
--assets-link
\"
{
\\\"
url
\\\"
:
\\\"
https://example.com/assets/1
\\\"
,
\\\"
name
\\\"
:
\\\"
asset1
\\\"
}
\"
"
],
"timeout"
=>
3600
,
"when"
=>
"on_success"
,
"allow_failure"
=>
false
...
...
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