Support for release key in gitlab-ci.yaml
What does this MR do?
A new node is added to the gitlab-ci.yaml
file to support the creation of Releases. This MR will define the nodes added , validate them and make the parsed configuration available to the pipelines. The code to process the configuration will not be included in this MR.
The Release will only be created if the job is processed without error. If an error is returned
from Rails API during Release creation, the release
job will fail. There can multiple
release
jobs in a pipeline
release:
stage: release
only: tags
script:
- make changelog | tee release_changelog.txt
release:
name: Release $CI_TAG_NAME
tag_name: v0.06
description: ./release_changelog.txt
assets:
links:
- name: cool-app.zip
url: http://my.awesome.download.site/1.0-$CI_COMMIT_SHORT_SHA.zip
- name: cool-app.exe
url: http://my.awesome.download.site/1.0-$CI_COMMIT_SHORT_SHA.exe
These methods are supported:
-
tag_name
- mandatory -
name
- optional -
description
- mandatory -
assets
- optional -
assets:links:name
- optional -
assets:links:url
- mandatory ifassets
specified
release:tag_name
The tag_name
must be specified, and this can either refer to a Git tag or can be specified by the user.
If the $CI_COMMIT_TAG
predefined variable is specified
as a tag name, it is necessary to also specify only: [tags]
, otherwise the job will fail when
running against branches.
When the specified tag doesn't exist in repository, a new tag will be created from the associated
ref
of the pipeline. In this case, the tag will point to the latest commit of the ref
,
instead of the associated SHA of the pipeline.
For example, when creating a Release from a Git tag creation:
job:
release:
tag_name: $CI_COMMIT_TAG
description: changelog.txt
only:
- tags
It is also possible to create any unique tag, in which case only: tags
is not mandatory.
A semantic versioning example:
job:
release:
tag_name: ${MAJOR}_${MINOR}_${REVISION}
description: changelog.txt
- The Release will only be created if the main script of the job succeeded.
- If the Release already exists it will not update and will cause the job with
release
keyword to fail. - The
release
section executes after thescript
tag and before theafter_script
.
release:name
Specifies the Release name. This is an optional field, if omitted it will be populated with
release:tag_name
.
release:description
Specifies a file containing the longer description of the Release. This is a mandatory field and can point to a changelog.
release:assets
An array of release:assets:links
.
It is possible to add assets to a release, in the form of URLs pointing to an arbitrary external
location (such as a S3 bucket or package registry). Any external locations must be populated by
a code specified in the script
section.
job:
script:
- cd src
- go build hello-world.go
- make changelog | tee release_changelog.txt
release:
name: Release $CI_TAG_NAME
tag_name: v0.06
description: release_changelog.txt
assets:
- name: hello-world
url: https://s3.amazonaws.com/myapp_binaries/hello-world
The GitLab Runner will call the GitLab Rails API and create the Release object, adding assets as URLs if defined.
release:assets:links
An array of link
entries, optional.
release:
assets:
links:
- name: cool-app.zip
url: https://downloads.example.org/1.0-$CI_COMMIT_SHORT_SHA.zip
release:assets:links:url
Specifies any valid URL, mandatory if release:assets:links
are specified.
release:
assets:
links:
- url: https://downloads.example.org/cool-app.exe
release:assets:links:name
Optional entry. If this is provided, the release:assets:links:url
in the same links
array
element will be displayed using this name, instead of the raw URL.
release:
assets:
links:
- name: cool-app.zip
url: https://downloads.example.org/1.0-$CI_COMMIT_SHORT_SHA.zip
Tag Only jobs
This functionality has been moved to #118646 (closed)
Feature Flag
This feature will be controlled via a Feature Flag. Refer !19298 (comment 259989805)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation created/updated or follow-up review issue created -
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Part of #26013 (closed)
Merge request reports
Activity
changed milestone to %12.5
assigned to @sean_carroll
1 Warning This merge request is quite big (more than 703 lines changed), please consider splitting it into multiple merge requests. 2 Messages This merge request adds or changes files that require a review from the Database team. CHANGELOG missing: If this merge request doesn’t need a CHANGELOG entry, feel free to ignore this message. You can create one with:
bin/changelog -m 19298 "Support for release key in gitlab-ci.yaml"
If you want to create a changelog entry for GitLab EE, run the following instead:
bin/changelog --ee -m 19298 "Support for release key in gitlab-ci.yaml"
Note: Merge requests with ~backstage, ci-build, meta do not trigger this check.
This merge request requires a database review. To make sure these changes are reviewed, take the following steps:
- Ensure the merge request has database and databasereview pending labels. If the merge request modifies database files, Danger will do this for you.
- Prepare your MR for database review according to the docs.
- Assign and mention the database reviewer suggested by Reviewer Roulette.
Reviewer roulette
Changes that require review have been detected! A merge request is normally reviewed by both a reviewer and a maintainer in its primary category (e.g. frontend or backend), and by a maintainer in all other categories.
To spread load more evenly across eligible reviewers, Danger has randomly picked a candidate for each review slot. Feel free to override this selection if you think someone else would be better-suited, or the chosen person is unavailable.
Once you've decided who will review this merge request, mention them as you normally would! Danger does not (yet?) automatically notify them for you.
Category Reviewer Maintainer backend Arthur Evstifeev ( @aevstifeev
)Imre Farkas ( @ifarkas
)database Tiger Watson ( @tigerwnz
)Mayra Cabrera ( @mayra-cabrera
)Generated by
DangerEdited by 🤖 GitLab Bot 🤖added database databasereview pending labels
mentioned in issue #26013 (closed)
- Resolved by Sean Carroll
@dosuken123 this is still a WIP, but could you review to see if I am on the right path here.
I'm not really clear why
bundle exec rspec spec/lib/gitlab/ci/yaml_processor_spec.rb:1058
is failing. If you have any insight that would be appreciated.
assigned to @ayufan
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
unassigned @ayufan
- Resolved by Sean Carroll
@ayufan I've updated this MR based on the modified
release:
structure as discussed. It needs some more tests (I will add them). But, I'm blocked on one thing and was wondering if you could look over it?- I used
descr
instead ofdescription
as it was conflicting withGitlab::Config::Entry::Node
. I consideredalias_method
but it wasn't working (perhaps as it is mixed in?), but in any case I think this will cause other problems as downstream code will be expectingdescription
. Do you have any suggestions?
alias_method :description, :title remove_method :description
Many thanks!
Edited by Sean Carroll - I used
assigned to @ayufan
added missed:12.5 label
changed milestone to %12.6
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
mentioned in commit c945b68e
unassigned @ayufan
marked the checklist item Changelog entry as completed
marked the checklist item Documentation created/updated or follow-up review issue created as completed
marked the checklist item Code review guidelines as completed
marked the checklist item Merge request performance guidelines as completed
marked the checklist item Style guides as completed
mentioned in commit c08d09c6
mentioned in commit 84bf790b
mentioned in commit 309588d4
added 2195 commits
-
019a7b92...c3f023eb - 2193 commits from branch
master
- 309588d4 - Add release key to gitlab-ci.yaml
- 46921809 - Additional tests
-
019a7b92...c3f023eb - 2193 commits from branch
mentioned in commit 7b06e474
added 235 commits
-
4d075d5a...14eb7a47 - 234 commits from branch
master
- 7b06e474 - Support for release key in gitlab-ci.yaml
-
4d075d5a...14eb7a47 - 234 commits from branch
mentioned in commit 048047f4
mentioned in commit 78369787
added 92 commits
-
048047f4...f8e60ae6 - 91 commits from branch
master
- 78369787 - Support for release key in gitlab-ci.yaml
-
048047f4...f8e60ae6 - 91 commits from branch
mentioned in merge request !20632 (merged)
mentioned in commit 39a76f2a
mentioned in commit b320eec1
mentioned in commit 18e2e689
mentioned in commit dcd771fc
@dosuken123 assigned to you for review.
Please note the
description
conflict still exists. I have temporarily changed the entry name todesc
, as removingAttributable
meant that thelib/gitlab/ci/config/entry/release.rb
spec was failing, as well as others, due to redefinition.Not sure what the best way forward on this is, suggestions welcome.
Edited by Sean Carrollmentioned in commit bbdce289
added 184 commits
-
dcd771fc...fede9077 - 183 commits from branch
master
- bbdce289 - Support for release key in gitlab-ci.yaml
-
dcd771fc...fede9077 - 183 commits from branch
mentioned in commit 7122ec7a
added 181 commits
-
bbdce289...26886d56 - 180 commits from branch
master
- 7122ec7a - Support for release key in gitlab-ci.yaml
-
bbdce289...26886d56 - 180 commits from branch
mentioned in commit cc9eb4c3
added 21 commits
-
7122ec7a...38bd0126 - 20 commits from branch
master
- cc9eb4c3 - Support for release key in gitlab-ci.yaml
-
7122ec7a...38bd0126 - 20 commits from branch
mentioned in commit 3d73f7fb
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
@sean_carroll Thanks. Overall LGTM. I left a few comments, but probably an important question is !19298 (comment 251749031). I think we should have
tag
ortag_name
keyword underrelease
, as it's consistent with Release API format. Let me know what you think.added 1 commit
- 96bbaaa9 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
added 1 commit
- e6986a3e - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
added 2 commits
added workflowin review label and removed workflowin dev label
mentioned in commit 95210fa0
added 1352 commits
-
d024491a...a36d844f - 1346 commits from branch
master
- 95210fa0 - Support for release key in gitlab-ci.yaml
- 65bf9e16 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- 7c82745e - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- 7caad42c - Remove changelog as suggested
- a24bcc95 - Apply reviewer suggestions
- cc528118 - Rename tag to tag_name
Toggle commit list-
d024491a...a36d844f - 1346 commits from branch
mentioned in commit 0860d055
added 45 commits
-
cc528118...1326e4fd - 39 commits from branch
master
- 0860d055 - Support for release key in gitlab-ci.yaml
- b13cdd55 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- fc198e59 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- d200911d - Remove changelog as suggested
- 3ac9d7dc - Apply reviewer suggestions
- 4f6f392e - Rename tag to tag_name
Toggle commit list-
cc528118...1326e4fd - 39 commits from branch
mentioned in commit 53f94602
added 203 commits
-
a661763e...5f56d89c - 194 commits from branch
master
- 53f94602 - Support for release key in gitlab-ci.yaml
- 9fffc955 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- 9c7cfaef - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- 3118c694 - Remove changelog as suggested
- afdf5ee8 - Apply reviewer suggestions
- 2967c6e3 - Rename tag to tag_name
- 7f1862ce - Fix release spec
- 50fd0237 - Add rules for CI_COMMIT_TAG
- b4c3835c - Fix linter issues
Toggle commit list-
a661763e...5f56d89c - 194 commits from branch
mentioned in commit 68379d50
added 45 commits
-
9224b568...71da2ba2 - 34 commits from branch
master
- 68379d50 - Support for release key in gitlab-ci.yaml
- 7d3bff25 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- 13ccf2d6 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb
- 7908d8b6 - Remove changelog as suggested
- f13c7937 - Apply reviewer suggestions
- 32bea7e3 - Rename tag to tag_name
- fb5b840a - Fix release spec
- 1a8015d9 - Add rules for CI_COMMIT_TAG
- 89734ff7 - Fix linter issues
- 8252a87c - Change release to symbol
- 845e0413 - Added only tags
Toggle commit list-
9224b568...71da2ba2 - 34 commits from branch
mentioned in commit bc191bbf
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
- Resolved by Sean Carroll
@sean_carroll Thanks. It looks nice
One concern is the evaluation for$CI_COMMIT_TAG
. It's actually more tricky than the current code, so that I'd say we should improve in the future MR than tackling the problem in this MR.Also, we might want to use feature flag to disable the feature by default until the whole feature is complete (Please take a look at https://about.gitlab.com/handbook/engineering/development/ci-cd/release/#issue-template-for-a-feature-development). This lets us avoid unexpected behavior from the incomplete feature on production server. In this feature's case, I'd suggest something like this
module Seed class Build < Seed::Base def initialize(pipeline, attributes, previous_stages) @resource_group_key = attributes.delete(:resource_group_key) attributes.fetch(:options, {})&.delete(:release) unless Feature.enabled?(:ci_release_generation, @project)
(We might be able to check the flag in
Config::Entry
level, instead)Edited by Shinya Maeda- Resolved by Sean Carroll
One concern is the evaluation for
$CI_COMMIT_TAG
. It's actually more tricky than the current code, so that I'd say we should improve in the future MR than tackling the problem in this MR.@dosuken123 I'm not clear on this. Do you mean to split support for
$CI_COMMIT_TAG
out?Edited by Sean Carroll
mentioned in issue #118439
Summary of scope clarifications:
- Move config to it's own table, #118439
- Control this feature with a Feature flag
- Expand
only: ['tags']
, possibly in a new MR.
Edited by Sean Carroll- Resolved by Shinya Maeda
@dosuken123, based on today's call and the comments about
$CI_COMMIT_TAG
!19298 (comment 260879118), then to complete this MR two things are needed:- Remove the logic surrounding validation of
$CI_COMMIT_TAG
and create a new issue to track this, probably viabuild.tag?
orpipeline.tag?
- Wrap this code in a Feature flag !19298 (comment 259989805)
WDYT ?
Edited by Sean Carroll - Remove the logic surrounding validation of
mentioned in commit 36dd9092
added 547 commits
-
b4c45fc5...467b0e70 - 538 commits from branch
master
- 36dd9092 - Support for release key in gitlab-ci.yaml
- a2e681de - Fix linter errors
- 1bf6b768 - Support embedded $CI_COMMIT_TAG
- f182b6eb - Apply reviewer suggestion
- 00f76ec2 - Apply reviewer suggestion
- 2204863b - Apply reviewer suggestions
- a2f75a11 - Fix linter issues
- 026bec14 - Apply reviewer suggestion
- 72edb77d - Add feature flag
Toggle commit list-
b4c45fc5...467b0e70 - 538 commits from branch
mentioned in issue #118646 (closed)
mentioned in commit 8e49e22a
mentioned in commit f9be13f7
mentioned in commit 68d8bd78
Tag-only jobs validation has been moved to #118646 (closed)
added 101 commits
-
467b0e70...5a6ebe09 - 101 commits from branch
master
-
467b0e70...5a6ebe09 - 101 commits from branch
- Resolved by Shinya Maeda
Assigned to @dosuken123 for review.
mentioned in commit 270dea95
mentioned in commit 9a77c3e5
added 201 commits
-
5a6ebe09...b5832553 - 200 commits from branch
master
- 9a77c3e5 - Support for release key in gitlab-ci.yaml
-
5a6ebe09...b5832553 - 200 commits from branch
mentioned in commit 92fc6934
mentioned in commit d2bfa168
added 1 commit
- 2f8e4e31 - Remove merge_trains_enabled column from project_ci_cd_settings table
mentioned in commit 2a95a1e7
mentioned in commit d97d6d37
added 98 commits
-
2a95a1e7...cd688518 - 97 commits from branch
master
- d97d6d37 - Support for release key in gitlab-ci.yaml
-
2a95a1e7...cd688518 - 97 commits from branch
mentioned in commit ffdf2421
- Resolved by Sean Carroll
@sean_carroll Thanks. It looks good to me
I left one nitpick, but it's not big deal.mentioned in commit 039e23e8
Assigned to @ayufan for maintainer approval.
assigned to @ayufan
changed milestone to %12.7
added missed:12.6 label
added missed-deliverable label
mentioned in commit 14c4f9ea
added 565 commits
-
039e23e8...403b60b1 - 564 commits from branch
master
- 14c4f9ea - Support for release key in gitlab-ci.yaml
-
039e23e8...403b60b1 - 564 commits from branch
@ayufan I just rebased this against
master
. It is ready for maintainer review. Thanks!mentioned in commit 234ebded
added 443 commits
-
0b03005e...9e71803b - 441 commits from branch
master
- 234ebded - Support for release key in gitlab-ci.yaml
- 24bebecc - Fix linter issue
-
0b03005e...9e71803b - 441 commits from branch
- Resolved by Sean Carroll
Thanks this looks good. I only have one suggestion.
I think that this is a first step, as it misses the persisting of the
release:
anywhere. We only parse it.Can we somehow comment it in either code, or as part of separate issue?
mentioned in commit b249b751
- Resolved by Kamil Trzciński
Thanks @ayufan
I think that this is a first step, as it misses the persisting of the
release:
anywhere. We only parse it.I'm not clear on that, I would have expected it to be already persisted in
ci_builds.options
with the rest of the.gitlab-ci.yaml
.I have opened a new issue to handle the persistence. Could you possibly point me to where persistence is handled for the rest of the yaml?
Edited by Sean Carroll
mentioned in issue #196110 (closed)
Assigned to @ayufan for maintainer review.
- Resolved by Kamil Trzciński
mentioned in issue #196171 (closed)
mentioned in commit 62914e26
mentioned in commit 0130c0fb
removed direction label
mentioned in merge request gitlab-com/www-gitlab-com!39076 (merged)
mentioned in issue #207842 (closed)
mentioned in merge request !26385 (merged)
mentioned in merge request !32528 (closed)
mentioned in merge request !48365 (merged)
mentioned in issue release-cli#128