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
096626ab
Commit
096626ab
authored
Aug 25, 2020
by
Nasko Vasilev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CI predefined environment variable CI_COMMIT_TIMESTAMP
parent
ca143cd3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
1 deletion
+21
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+7
-0
app/models/commit.rb
app/models/commit.rb
+5
-1
changelogs/unreleased/34281-add-ci-variable-commit-timestamp.yml
...ogs/unreleased/34281-add-ci-variable-commit-timestamp.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
-0
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
+1
-0
No files found.
app/models/ci/pipeline.rb
View file @
096626ab
...
...
@@ -491,6 +491,12 @@ module Ci
end
end
def
git_commit_timestamp
strong_memoize
(
:git_commit_timestamp
)
do
commit
.
try
(
:timestamp
)
end
end
def
before_sha
super
||
Gitlab
::
Git
::
BLANK_SHA
end
...
...
@@ -768,6 +774,7 @@ module Ci
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
)
variables
.
append
(
key:
'CI_COMMIT_REF_PROTECTED'
,
value:
(
!!
protected_ref?
).
to_s
)
variables
.
append
(
key:
'CI_COMMIT_TIMESTAMP'
,
value:
git_commit_timestamp
.
to_s
)
# legacy variables
variables
.
append
(
key:
'CI_BUILD_REF'
,
value:
sha
)
...
...
app/models/commit.rb
View file @
096626ab
...
...
@@ -221,12 +221,16 @@ class Commit
description
.
present?
end
def
timestamp
committed_date
.
xmlschema
end
def
hook_attrs
(
with_changed_files:
false
)
data
=
{
id:
id
,
message:
safe_message
,
title:
title
,
timestamp:
committed_date
.
xmlschema
,
timestamp:
timestamp
,
url:
Gitlab
::
UrlBuilder
.
build
(
self
),
author:
{
name:
author_name
,
...
...
changelogs/unreleased/34281-add-ci-variable-commit-timestamp.yml
0 → 100644
View file @
096626ab
---
title
:
Add CI_COMMIT_TIMESTAMP CI variable
merge_request
:
40388
author
:
Nasko Vasilev
type
:
added
doc/ci/variables/predefined_variables.md
View file @
096626ab
...
...
@@ -43,6 +43,7 @@ Kubernetes-specific environment variables are detailed in the
|
`CI_COMMIT_BRANCH`
| 12.6 | 0.5 | The commit branch name. Present only when building branches. |
|
`CI_COMMIT_TAG`
| 9.0 | 0.5 | The commit tag name. Present only when building tags. |
|
`CI_COMMIT_TITLE`
| 10.8 | all | The title of the commit - the full first line of the message |
|
`CI_COMMIT_TIMESTAMP`
| 13.4 | all | The timestamp of the commit in the ISO 8601 format. |
|
`CI_CONCURRENT_ID`
| all | 11.10 | Unique ID of build execution within a single executor. |
|
`CI_CONCURRENT_PROJECT_ID`
| all | 11.10 | Unique ID of build execution within a single executor and project. |
|
`CI_CONFIG_PATH`
| 9.4 | 0.5 | The path to CI configuration file. Defaults to
`.gitlab-ci.yml`
|
...
...
spec/models/ci/bridge_spec.rb
View file @
096626ab
...
...
@@ -50,6 +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
]
expect
(
bridge
.
scoped_variables_hash
.
keys
).
to
include
(
*
variables
)
...
...
spec/models/ci/build_spec.rb
View file @
096626ab
...
...
@@ -2329,6 +2329,7 @@ RSpec.describe Ci::Build do
{
key:
'CI_COMMIT_TITLE'
,
value:
pipeline
.
git_commit_title
,
public:
true
,
masked:
false
},
{
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_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 @
096626ab
...
...
@@ -715,6 +715,7 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
CI_COMMIT_TITLE
CI_COMMIT_DESCRIPTION
CI_COMMIT_REF_PROTECTED
CI_COMMIT_TIMESTAMP
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