Skip to content
Snippets Groups Projects

Support for release key in gitlab-ci.yaml

Merged Sean Carroll requested to merge 26013-release-generation-from-within-gitlab-ci-yml-2 into master
All threads resolved!

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 if assets 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 the script tag and before the after_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

Availability and Testing

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)

Edited by Sean Carroll

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • It seems already reviewed by kamil so I will not go through for now. Feel free to assign me back when you need review from my side.

  • Sean Carroll changed the description

    changed the description

  • Sean Carroll added 1 commit
  • Sean Carroll added 1 commit

    added 1 commit

    • 39058b50 - Add release key to gitlab-ci.yaml

    Compare with previous version

    • 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 of description as it was conflicting with Gitlab::Config::Entry::Node. I considered alias_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 expecting description. Do you have any suggestions?
      alias_method :description, :title
      remove_method :description 

      Many thanks!

      Edited by Sean Carroll
  • assigned to @ayufan

  • Sean Carroll added 1 commit

    added 1 commit

    • b1c59521 - Add release key to gitlab-ci.yaml

    Compare with previous version

  • 🤖 GitLab Bot 🤖 changed milestone to %12.6

    changed milestone to %12.6

  • Sean Carroll mentioned in commit c945b68e

    mentioned in commit c945b68e

  • Sean Carroll added 1 commit

    added 1 commit

    • c945b68e - Add release key to gitlab-ci.yaml

    Compare with previous version

  • unassigned @ayufan

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll marked the checklist item Changelog entry as completed

    marked the checklist item Changelog entry as completed

  • Sean Carroll marked the checklist item Code review guidelines as completed

    marked the checklist item Code review guidelines as completed

  • Sean Carroll marked the checklist item Merge request performance guidelines as completed

    marked the checklist item Merge request performance guidelines as completed

  • Sean Carroll marked the checklist item Style guides as completed

    marked the checklist item Style guides as completed

  • Sean Carroll mentioned in commit c08d09c6

    mentioned in commit c08d09c6

  • Sean Carroll added 1 commit

    added 1 commit

    • c08d09c6 - Add release key to gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit 84bf790b

    mentioned in commit 84bf790b

  • Sean Carroll added 1 commit

    added 1 commit

    • 84bf790b - Add release key to gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit 309588d4

    mentioned in commit 309588d4

  • Sean Carroll added 2195 commits

    added 2195 commits

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit
  • Sean Carroll mentioned in commit 7b06e474

    mentioned in commit 7b06e474

  • Sean Carroll changed the description

    changed the description

  • Sean Carroll added 235 commits

    added 235 commits

    Compare with previous version

  • Sean Carroll mentioned in commit 048047f4

    mentioned in commit 048047f4

  • Sean Carroll added 1 commit

    added 1 commit

    • 048047f4 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit 78369787

    mentioned in commit 78369787

  • Sean Carroll added 92 commits

    added 92 commits

    Compare with previous version

  • Sean Carroll mentioned in merge request !20632 (merged)

    mentioned in merge request !20632 (merged)

  • Sean Carroll mentioned in commit 39a76f2a

    mentioned in commit 39a76f2a

  • Sean Carroll added 1 commit

    added 1 commit

    • 39a76f2a - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit b320eec1

    mentioned in commit b320eec1

  • Sean Carroll added 1 commit

    added 1 commit

    • b320eec1 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit 18e2e689

    mentioned in commit 18e2e689

  • Sean Carroll added 1 commit

    added 1 commit

    • 18e2e689 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit dcd771fc

    mentioned in commit dcd771fc

  • Sean Carroll added 1 commit

    added 1 commit

    • dcd771fc - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll changed the description

    changed the description

  • Sean Carroll resolved all threads

    resolved all threads

  • Sean Carroll unmarked as a Work In Progress

    unmarked as a Work In Progress

  • @dosuken123 assigned to you for review.

    Please note the description conflict still exists. I have temporarily changed the entry name to desc, as removing Attributable meant that the lib/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. :smile:

    Edited by Sean Carroll
  • Sean Carroll assigned to @dosuken123

    assigned to @dosuken123

  • Sean Carroll mentioned in commit bbdce289

    mentioned in commit bbdce289

  • Sean Carroll added 184 commits

    added 184 commits

    Compare with previous version

  • Sean Carroll mentioned in commit 7122ec7a

    mentioned in commit 7122ec7a

  • Sean Carroll added 181 commits

    added 181 commits

    Compare with previous version

  • Sean Carroll mentioned in commit cc9eb4c3

    mentioned in commit cc9eb4c3

  • Sean Carroll added 21 commits

    added 21 commits

    Compare with previous version

  • Sean Carroll mentioned in commit 3d73f7fb

    mentioned in commit 3d73f7fb

  • Sean Carroll added 1 commit

    added 1 commit

    • 3d73f7fb - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Hi @dosuken123 I think this is good to go now, could you please review.

  • @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 or tag_name keyword under release, as it's consistent with Release API format. Let me know what you think.

  • Shinya Maeda unassigned @dosuken123

    unassigned @dosuken123

  • Sean Carroll added 1 commit

    added 1 commit

    • 96bbaaa9 - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    • e6986a3e - Apply suggestion to spec/services/ci/create_pipeline_service_spec.rb

    Compare with previous version

  • Sean Carroll added 2 commits

    added 2 commits

    • d3490842 - Remove changelog as suggested
    • a45180c6 - Apply reviewer suggestions

    Compare with previous version

  • added workflowin review label and removed workflowin dev label

  • Sean Carroll changed the description

    changed the description

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit 95210fa0

    mentioned in commit 95210fa0

  • Sean Carroll added 1352 commits

    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

    Compare with previous version

  • Sean Carroll mentioned in commit 0860d055

    mentioned in commit 0860d055

  • Sean Carroll added 45 commits

    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

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit 53f94602

    mentioned in commit 53f94602

  • Sean Carroll added 203 commits

    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

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit 68379d50

    mentioned in commit 68379d50

  • Sean Carroll added 45 commits

    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

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit bc191bbf

    mentioned in commit bc191bbf

  • Sean Carroll added 1 commit

    added 1 commit

    • bc191bbf - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Added support for $CI_COMMIT_TAG

    Assigned to @dosuken123 for review.

  • Sean Carroll assigned to @dosuken123

    assigned to @dosuken123

  • @sean_carroll Thanks. It looks nice :thumbsup: 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
  • Shinya Maeda unassigned @dosuken123

    unassigned @dosuken123

    • 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
  • Sean Carroll added 1 commit

    added 1 commit

    • e9772324 - Support embedded $CI_COMMIT_TAG

    Compare with previous version

  • Sean Carroll changed the description

    changed the description

  • Sean Carroll changed the description

    changed the description

  • Sean Carroll mentioned in issue #118439

    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
  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll resolved all threads

    resolved all threads

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit 36dd9092

    mentioned in commit 36dd9092

  • Sean Carroll added 547 commits

    added 547 commits

    Compare with previous version

  • mentioned in issue #118646 (closed)

  • Sean Carroll mentioned in commit 8e49e22a

    mentioned in commit 8e49e22a

  • Sean Carroll added 1 commit

    added 1 commit

    • 8e49e22a - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit f9be13f7

    mentioned in commit f9be13f7

  • Sean Carroll mentioned in commit 68d8bd78

    mentioned in commit 68d8bd78

  • Sean Carroll added 1 commit

    added 1 commit

    • 68d8bd78 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll changed the description

    changed the description

  • Tag-only jobs validation has been moved to #118646 (closed)

  • Sean Carroll added 101 commits

    added 101 commits

    Compare with previous version

  • Sean Carroll assigned to @dosuken123

    assigned to @dosuken123

  • Sean Carroll mentioned in commit 270dea95

    mentioned in commit 270dea95

  • Sean Carroll mentioned in commit 9a77c3e5

    mentioned in commit 9a77c3e5

  • Sean Carroll added 201 commits

    added 201 commits

    Compare with previous version

  • Sean Carroll mentioned in commit 92fc6934

    mentioned in commit 92fc6934

  • Sean Carroll added 1 commit

    added 1 commit

    • 92fc6934 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit d2bfa168

    mentioned in commit d2bfa168

  • Sean Carroll added 1 commit

    added 1 commit

    • d2bfa168 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll added 1 commit

    added 1 commit

    • 2f8e4e31 - Remove merge_trains_enabled column from project_ci_cd_settings table

    Compare with previous version

  • Sean Carroll mentioned in commit 2a95a1e7

    mentioned in commit 2a95a1e7

  • Sean Carroll added 1 commit

    added 1 commit

    • 2a95a1e7 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Sean Carroll mentioned in commit d97d6d37

    mentioned in commit d97d6d37

  • Sean Carroll added 98 commits

    added 98 commits

    Compare with previous version

  • Sean Carroll mentioned in commit ffdf2421

    mentioned in commit ffdf2421

  • Sean Carroll added 1 commit

    added 1 commit

    • ffdf2421 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Shinya Maeda resolved all threads

    resolved all threads

  • Shinya Maeda approved this merge request

    approved this merge request

  • @sean_carroll Thanks. It looks good to me :thumbsup: I left one nitpick, but it's not big deal.

  • Shinya Maeda unassigned @dosuken123

    unassigned @dosuken123

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll resolved all threads

    resolved all threads

  • Sean Carroll mentioned in commit 039e23e8

    mentioned in commit 039e23e8

  • Sean Carroll added 1 commit

    added 1 commit

    • 039e23e8 - Support for release key in gitlab-ci.yaml

    Compare with previous version

  • Assigned to @ayufan for maintainer approval.

  • assigned to @ayufan

  • Sean Carroll resolved all threads

    resolved all threads

  • 🤖 GitLab Bot 🤖 changed milestone to %12.7

    changed milestone to %12.7

  • Sean Carroll mentioned in commit 14c4f9ea

    mentioned in commit 14c4f9ea

  • Sean Carroll added 565 commits

    added 565 commits

    Compare with previous version

  • @ayufan I just rebased this against master. It is ready for maintainer review. Thanks!

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit 234ebded

    mentioned in commit 234ebded

  • Sean Carroll added 443 commits

    added 443 commits

    Compare with previous version

  • Rebased against master.

  • @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?

  • Sean Carroll added 1 commit

    added 1 commit

    Compare with previous version

  • Sean Carroll mentioned in commit b249b751

    mentioned in commit b249b751

  • Sean Carroll added 1 commit

    added 1 commit

    • b249b751 - Support for release key in gitlab-ci.yaml

    Compare with previous version

    • 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)

  • Sean Carroll resolved all threads

    resolved all threads

  • Assigned to @ayufan for maintainer review.

  • Kamil Trzciński
  • Kamil Trzciński resolved all threads

    resolved all threads

  • mentioned in issue #196171 (closed)

  • Kamil Trzciński approved this merge request

    approved this merge request

  • mentioned in commit 62914e26

  • Sean Carroll mentioned in commit 0130c0fb

    mentioned in commit 0130c0fb

  • removed direction label

  • Leo Lu mentioned in issue #207842 (closed)

    mentioned in issue #207842 (closed)

  • Sean Carroll mentioned in merge request !26385 (merged)

    mentioned in merge request !26385 (merged)

  • Sean Carroll mentioned in merge request !32528 (closed)

    mentioned in merge request !32528 (closed)

  • mentioned in merge request !48365 (merged)

  • mentioned in issue release-cli#128

  • Please register or sign in to reply
    Loading