Merge branch 'add-git-commit-message-predefined-variable' into 'master'
Add CI_COMMIT_MESSAGE, CI_COMMIT_TITLE and CI_COMMIT_DESCRIPTION predefined variables Closes #20400 See merge request gitlab-org/gitlab-ce!18672
This commit is contained in:
commit
e1f6400f31
5 changed files with 40 additions and 6 deletions
|
@ -271,19 +271,39 @@ module Ci
|
|||
end
|
||||
|
||||
def git_author_name
|
||||
commit.try(:author_name)
|
||||
strong_memoize(:git_author_name) do
|
||||
commit.try(:author_name)
|
||||
end
|
||||
end
|
||||
|
||||
def git_author_email
|
||||
commit.try(:author_email)
|
||||
strong_memoize(:git_author_email) do
|
||||
commit.try(:author_email)
|
||||
end
|
||||
end
|
||||
|
||||
def git_commit_message
|
||||
commit.try(:message)
|
||||
strong_memoize(:git_commit_message) do
|
||||
commit.try(:message)
|
||||
end
|
||||
end
|
||||
|
||||
def git_commit_title
|
||||
commit.try(:title)
|
||||
strong_memoize(:git_commit_title) do
|
||||
commit.try(:title)
|
||||
end
|
||||
end
|
||||
|
||||
def git_commit_full_title
|
||||
strong_memoize(:git_commit_full_title) do
|
||||
commit.try(:full_title)
|
||||
end
|
||||
end
|
||||
|
||||
def git_commit_description
|
||||
strong_memoize(:git_commit_description) do
|
||||
commit.try(:description)
|
||||
end
|
||||
end
|
||||
|
||||
def short_sha
|
||||
|
@ -493,6 +513,9 @@ module Ci
|
|||
.append(key: 'CI_PIPELINE_ID', value: id.to_s)
|
||||
.append(key: 'CI_CONFIG_PATH', value: ci_yaml_file_path)
|
||||
.append(key: 'CI_PIPELINE_SOURCE', value: source.to_s)
|
||||
.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message)
|
||||
.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title)
|
||||
.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description)
|
||||
end
|
||||
|
||||
def queued_duration
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Add CI_COMMIT_MESSAGE, CI_COMMIT_TITLE and CI_COMMIT_DESCRIPTION predefined variables
|
||||
merge_request: 18672
|
||||
author:
|
||||
type: added
|
|
@ -41,6 +41,9 @@ future GitLab releases.**
|
|||
| **CI_COMMIT_REF_SLUG** | 9.0 | all | `$CI_COMMIT_REF_NAME` lowercased, shortened to 63 bytes, and with everything except `0-9` and `a-z` replaced with `-`. No leading / trailing `-`. Use in URLs, host names and domain names. |
|
||||
| **CI_COMMIT_SHA** | 9.0 | all | The commit revision for which project is built |
|
||||
| **CI_COMMIT_TAG** | 9.0 | 0.5 | The commit tag name. Present only when building tags. |
|
||||
| **CI_COMMIT_MESSAGE** | 10.8 | all | The full commit message. |
|
||||
| **CI_COMMIT_TITLE** | 10.8 | all | The title of the commit - the full first line of the message |
|
||||
| **CI_COMMIT_DESCRIPTION** | 10.8 | all | The description of the commit: the message without first line, if the title is shorter than 100 characters; full message in other case. |
|
||||
| **CI_CONFIG_PATH** | 9.4 | 0.5 | The path to CI config file. Defaults to `.gitlab-ci.yml` |
|
||||
| **CI_DEBUG_TRACE** | all | 1.7 | Whether [debug tracing](#debug-tracing) is enabled |
|
||||
| **CI_DISPOSABLE_ENVIRONMENT** | all | 10.1 | Marks that the job is executed in a disposable environment (something that is created only for this job and disposed of/destroyed after the execution - all executors except `shell` and `ssh`). If the environment is disposable, it is set to true, otherwise it is not defined at all. |
|
||||
|
|
|
@ -1518,7 +1518,10 @@ describe Ci::Build do
|
|||
{ key: 'CI_PROJECT_VISIBILITY', value: 'private', public: true },
|
||||
{ key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true },
|
||||
{ key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, public: true },
|
||||
{ key: 'CI_PIPELINE_SOURCE', value: pipeline.source, public: true }
|
||||
{ key: 'CI_PIPELINE_SOURCE', value: pipeline.source, public: true },
|
||||
{ key: 'CI_COMMIT_MESSAGE', value: pipeline.git_commit_message, public: true },
|
||||
{ key: 'CI_COMMIT_TITLE', value: pipeline.git_commit_title, public: true },
|
||||
{ key: 'CI_COMMIT_DESCRIPTION', value: pipeline.git_commit_description, public: true }
|
||||
]
|
||||
end
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ describe Ci::Pipeline, :mailer do
|
|||
it 'includes all predefined variables in a valid order' do
|
||||
keys = subject.map { |variable| variable[:key] }
|
||||
|
||||
expect(keys).to eq %w[CI_PIPELINE_ID CI_CONFIG_PATH CI_PIPELINE_SOURCE]
|
||||
expect(keys).to eq %w[CI_PIPELINE_ID CI_CONFIG_PATH CI_PIPELINE_SOURCE CI_COMMIT_MESSAGE CI_COMMIT_TITLE CI_COMMIT_DESCRIPTION]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue