Provide Release Description from Tag in CI/CD pipeline variable
Release notes
Previously, there was no easy way to refer to release notes associated with a tag or a release as part of a pipeline. With this update, you can now easily refer to this information by using two new predefined environment variables, $CI_COMMIT_TAG_MESSAGE
and $CI_RELEASE_DESCRIPTION
. This allows you to incorporate this information as part of your deploy workflow.
Problem to solve
Allow easy access to the release description in the CI/CD pipeline.
Further details
I want to access the Release notes associated with a tag so that I can use them when creating a release in Octopus Deploy. Currently I can't see any way of doing this short of writing code to pull the data from the Tags API.
We tag new versions of our software with a tag such as "v1.0.0". We have GitLab CI/CD setup to deploy the new version to our S3 bucket when such a tag is pushed. We also deploy release notes along side the artifact. There's a variable called $CI_COMMIT_TAG
to get the tag name, but there's no such variable to get the tag message. I know there are still ways to get it, but I want to save time by being able to use a simple environment variable.
Proposal
Simply make the release notes available as a variable in the CI/CD pipeline.
introduce a CI/CD env variable such as $CI_COMMIT_TAG_MESSAGE
. Possibly also $CI_COMMIT_TAG_RELEASE_NOTES
.
What does success look like, and how can we measure that?
Release notes text is available as a CI_ variable within the CI/CD pipeline.
Implementation
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 1e328c3c573..cb1d2ab4a4d 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -851,6 +851,8 @@ def predefined_commit_variables
variables.append(key: 'CI_COMMIT_REF_SLUG', value: source_ref_slug)
variables.append(key: 'CI_COMMIT_BRANCH', value: ref) if branch?
variables.append(key: 'CI_COMMIT_TAG', value: ref) if tag?
+ variables.append(key: 'CI_COMMIT_TAG_MESSAGE', value: project.repository.find_tag(ref).message) if tag?
+ variables.append(key: 'CI_COMMIT_TAG_RELEASE_NOTES', value: project.releases.find_by(tag: ref).description) if tag?
variables.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message.to_s)
variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s)
variables.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description.to_s)