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
751a1db1
Commit
751a1db1
authored
Mar 23, 2021
by
Craig Andrews
Committed by
Shinya Maeda
Mar 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GIT_COMMIT_AUTHOR predefined variable
Signed-off-by:
Craig Andrews
<
candrews@integralblue.com
>
parent
4e4ca479
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
1 deletion
+25
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+7
-0
app/models/commit.rb
app/models/commit.rb
+8
-0
changelogs/unreleased/candrews-master-patch-98104.yml
changelogs/unreleased/candrews-master-patch-98104.yml
+5
-0
doc/ci/variables/predefined_variables.md
doc/ci/variables/predefined_variables.md
+1
-0
spec/models/ci/bridge_spec.rb
spec/models/ci/bridge_spec.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+2
-0
No files found.
app/models/ci/pipeline.rb
View file @
751a1db1
...
...
@@ -510,6 +510,12 @@ module Ci
end
end
def
git_author_full_text
strong_memoize
(
:git_author_full_text
)
do
commit
.
try
(
:author_full_text
)
end
end
def
git_commit_message
strong_memoize
(
:git_commit_message
)
do
commit
.
try
(
:message
)
...
...
@@ -822,6 +828,7 @@ module Ci
variables
.
append
(
key:
'CI_COMMIT_DESCRIPTION'
,
value:
git_commit_description
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_REF_PROTECTED'
,
value:
(
!!
protected_ref?
).
to_s
)
variables
.
append
(
key:
'CI_COMMIT_TIMESTAMP'
,
value:
git_commit_timestamp
.
to_s
)
variables
.
append
(
key:
'CI_COMMIT_AUTHOR'
,
value:
git_author_full_text
.
to_s
)
# legacy variables
variables
.
append
(
key:
'CI_BUILD_REF'
,
value:
sha
)
...
...
app/models/commit.rb
View file @
751a1db1
...
...
@@ -222,6 +222,14 @@ class Commit
end
end
def
author_full_text
return
unless
author_name
&&
author_email
strong_memoize
(
:author_full_text
)
do
"
#{
author_name
}
<
#{
author_email
}
>"
end
end
# Returns full commit message if title is truncated (greater than 99 characters)
# otherwise returns commit message without first line
def
description
...
...
changelogs/unreleased/candrews-master-patch-98104.yml
0 → 100644
View file @
751a1db1
---
title
:
"
Add
CI_COMMIT_AUTHOR
predefined
variable"
merge_request
:
56144
author
:
Craig Andrews @candrews
type
:
added
doc/ci/variables/predefined_variables.md
View file @
751a1db1
...
...
@@ -35,6 +35,7 @@ There are also [Kubernetes-specific deployment variables](../../user/project/clu
|
`CI_COMMIT_TAG`
| 9.0 | 0.5 | The commit tag name. Available only in pipelines for tags. |
|
`CI_COMMIT_TIMESTAMP`
| 13.4 | all | The timestamp of the commit in the ISO 8601 format. |
|
`CI_COMMIT_TITLE`
| 10.8 | all | The title of the commit. The full first line of the message. |
|
`CI_COMMIT_AUTHOR`
| 13.10 | all | The author of the commit in
`Name <email>`
format. |
|
`CI_CONCURRENT_ID`
| all | 11.10 | The unique ID of build execution in a single executor. |
|
`CI_CONCURRENT_PROJECT_ID`
| all | 11.10 | The unique ID of build execution in a single executor and project. |
|
`CI_CONFIG_PATH`
| 9.4 | 0.5 | The path to the CI/CD configuration file. Defaults to
`.gitlab-ci.yml`
. |
...
...
spec/models/ci/bridge_spec.rb
View file @
751a1db1
...
...
@@ -50,7 +50,7 @@ RSpec.describe Ci::Bridge do
CI_PROJECT_PATH_SLUG CI_PROJECT_NAMESPACE CI_PROJECT_ROOT_NAMESPACE
CI_PIPELINE_IID CI_CONFIG_PATH CI_PIPELINE_SOURCE CI_COMMIT_MESSAGE
CI_COMMIT_TITLE CI_COMMIT_DESCRIPTION CI_COMMIT_REF_PROTECTED
CI_COMMIT_TIMESTAMP
CI_COMMIT_TIMESTAMP
CI_COMMIT_AUTHOR
]
expect
(
bridge
.
scoped_variables
.
map
{
|
v
|
v
[
:key
]
}).
to
include
(
*
variables
)
...
...
spec/models/ci/build_spec.rb
View file @
751a1db1
...
...
@@ -2500,6 +2500,7 @@ RSpec.describe Ci::Build do
{
key:
'CI_COMMIT_DESCRIPTION'
,
value:
pipeline
.
git_commit_description
,
public:
true
,
masked:
false
},
{
key:
'CI_COMMIT_REF_PROTECTED'
,
value:
(
!!
pipeline
.
protected_ref?
).
to_s
,
public:
true
,
masked:
false
},
{
key:
'CI_COMMIT_TIMESTAMP'
,
value:
pipeline
.
git_commit_timestamp
,
public:
true
,
masked:
false
},
{
key:
'CI_COMMIT_AUTHOR'
,
value:
pipeline
.
git_author_full_text
,
public:
true
,
masked:
false
},
{
key:
'CI_BUILD_REF'
,
value:
build
.
sha
,
public:
true
,
masked:
false
},
{
key:
'CI_BUILD_BEFORE_SHA'
,
value:
build
.
before_sha
,
public:
true
,
masked:
false
},
{
key:
'CI_BUILD_REF_NAME'
,
value:
build
.
ref
,
public:
true
,
masked:
false
},
...
...
spec/models/ci/pipeline_spec.rb
View file @
751a1db1
...
...
@@ -40,6 +40,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
it
{
is_expected
.
to
respond_to
:git_author_name
}
it
{
is_expected
.
to
respond_to
:git_author_email
}
it
{
is_expected
.
to
respond_to
:git_author_full_text
}
it
{
is_expected
.
to
respond_to
:short_sha
}
it
{
is_expected
.
to
delegate_method
(
:full_path
).
to
(
:project
).
with_prefix
}
...
...
@@ -819,6 +820,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
CI_COMMIT_DESCRIPTION
CI_COMMIT_REF_PROTECTED
CI_COMMIT_TIMESTAMP
CI_COMMIT_AUTHOR
CI_BUILD_REF
CI_BUILD_BEFORE_SHA
CI_BUILD_REF_NAME
...
...
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