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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
0aedeb56
Commit
0aedeb56
authored
Jun 21, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add predefined CI variables to GitLab for container registry, pipelines, project name, etc.
parent
44b8b77e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
28 deletions
+67
-28
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/build.rb
app/models/ci/build.rb
+28
-4
doc/ci/variables/README.md
doc/ci/variables/README.md
+38
-24
No files found.
CHANGELOG
View file @
0aedeb56
...
...
@@ -29,6 +29,7 @@ v 8.9.0 (unreleased)
- Reduce number of fog gem dependencies
- Add number of merge requests for a given milestone to the milestones view.
- Implement a fair usage of shared runners
- Add predefined CI variables to GitLab for container registry, pipelines, project name, etc.
- Remove project notification settings associated with deleted projects
- Fix 404 page when viewing TODOs that contain milestones or labels in different projects
- Add a metric for the number of new Redis connections created by a transaction
...
...
app/models/ci/build.rb
View file @
0aedeb56
...
...
@@ -431,10 +431,34 @@ module Ci
def
predefined_variables
variables
=
[]
variables
<<
{
key: :CI_BUILD_TAG
,
value:
ref
,
public:
true
}
if
tag?
variables
<<
{
key: :CI_BUILD_NAME
,
value:
name
,
public:
true
}
variables
<<
{
key: :CI_BUILD_STAGE
,
value:
stage
,
public:
true
}
variables
<<
{
key: :CI_BUILD_TRIGGERED
,
value:
'true'
,
public:
true
}
if
trigger_request
variables
<<
{
key:
'CI'
,
value:
'true'
,
public:
true
}
variables
<<
{
key:
'GITLAB_CI'
,
value:
'true'
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_ID'
,
value:
id
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_TOKEN'
,
value:
token
,
public:
false
}
variables
<<
{
key:
'CI_BUILD_REF'
,
value:
sha
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_BEFORE_SHA'
,
value:
before_sha
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_REF_NAME'
,
value:
ref
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_TAG'
,
value:
ref
,
public:
true
}
if
tag?
variables
<<
{
key:
'CI_BUILD_NAME'
,
value:
name
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_STAGE'
,
value:
stage
,
public:
true
}
variables
<<
{
key:
'CI_BUILD_TRIGGERED'
,
value:
'true'
,
public:
true
}
if
trigger_request
variables
<<
{
key:
'CI_PIPELINE_ID'
,
value:
pipeline
.
id
,
public:
true
}
variables
<<
{
key:
'CI_PROJECT_ID'
,
value:
project_id
,
public:
true
}
variables
<<
{
key:
'CI_PROJECT_NAME'
,
value:
project
.
path
,
public:
true
}
variables
<<
{
key:
'CI_PROJECT_PATH'
,
value:
project
.
path_with_namespace
,
public:
true
}
variables
<<
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
project
.
namespace
.
path
,
public:
true
}
variables
<<
{
key:
'CI_PROJECT_URL'
,
value:
project
.
web_url
,
public:
true
}
variables
<<
{
key:
'CI_REGISTRY'
,
value:
Gitlab
.
config
.
registry
.
host_port
,
public:
true
}
if
Gitlab
.
config
.
registry
.
enabled
variables
<<
{
key:
'CI_REGISTRY_IMAGE'
,
value:
project
.
container_registry_repository_url
,
public:
true
}
if
project
.
container_registry_repository_url
variables
<<
{
key:
'CI_SERVER_NAME'
,
value:
'GitLab'
,
public:
true
}
variables
<<
{
key:
'CI_SERVER_VERSION'
,
value:
Gitlab
::
VERSION
,
public:
true
}
variables
<<
{
key:
'CI_SERVER_REVISION'
,
value:
Gitlab
::
REVISION
,
public:
true
}
variables
<<
{
key:
'CI_SERVER_URL'
,
value:
Gitlab
::
REVISION
,
public:
true
}
variables
end
end
...
...
doc/ci/variables/README.md
View file @
0aedeb56
...
...
@@ -18,25 +18,32 @@ The `API_TOKEN` will take the Secure Variable value: `SECURE`.
### Predefined variables (Environment Variables)
| Variable | Runner | Description |
|-------------------------|-----|--------|
|
**CI**
| 0.4 | Mark that build is executed in CI environment |
|
**GITLAB_CI**
| all | Mark that build is executed in GitLab CI environment |
|
**CI_SERVER**
| all | Mark that build is executed in CI environment |
|
**CI_SERVER_NAME**
| all | CI server that is used to coordinate builds |
|
**CI_SERVER_VERSION**
| all | Not yet defined |
|
**CI_SERVER_REVISION**
| all | Not yet defined |
|
**CI_BUILD_REF**
| all | The commit revision for which project is built |
|
**CI_BUILD_TAG**
| 0.5 | The commit tag name. Present only when building tags. |
|
**CI_BUILD_NAME**
| 0.5 | The name of the build as defined in
`.gitlab-ci.yml`
|
|
**CI_BUILD_STAGE**
| 0.5 | The name of the stage as defined in
`.gitlab-ci.yml`
|
|
**CI_BUILD_REF_NAME**
| all | The branch or tag name for which project is built |
|
**CI_BUILD_ID**
| all | The unique id of the current build that GitLab CI uses internally |
|
**CI_BUILD_REPO**
| all | The URL to clone the Git repository |
|
**CI_BUILD_TRIGGERED**
| 0.5 | The flag to indicate that build was [triggered] |
|
**CI_BUILD_TOKEN**
| 1.2 | Token used for authenticating with the GitLab Container Registry |
|
**CI_PROJECT_ID**
| all | The unique id of the current project that GitLab CI uses internally |
|
**CI_PROJECT_DIR**
| all | The full path where the repository is cloned and where the build is ran |
| Variable | GitLab | Runner | Description |
|-------------------------|--------|--------|-------------|
|
**CI**
| all | 0.4 | Mark that build is executed in CI environment |
|
**GITLAB_CI**
| all | all | Mark that build is executed in GitLab CI environment |
|
**CI_SERVER**
| all | all | Mark that build is executed in CI environment |
|
**CI_SERVER_NAME**
| all | all | The name of CI server that is used to coordinate builds |
|
**CI_SERVER_VERSION**
| all | all | GitLab version that is used to schedule builds |
|
**CI_SERVER_REVISION**
| all | all | GitLab revision that is used to schedule builds |
|
**CI_BUILD_ID**
| all | all | The unique id of the current build that GitLab CI uses internally |
|
**CI_BUILD_REF**
| all | all | The commit revision for which project is built |
|
**CI_BUILD_TAG**
| all | 0.5 | The commit tag name. Present only when building tags. |
|
**CI_BUILD_NAME**
| all | 0.5 | The name of the build as defined in
`.gitlab-ci.yml`
|
|
**CI_BUILD_STAGE**
| all | 0.5 | The name of the stage as defined in
`.gitlab-ci.yml`
|
|
**CI_BUILD_REF_NAME**
| all | all | The branch or tag name for which project is built |
|
**CI_BUILD_REPO**
| all | all | The URL to clone the Git repository |
|
**CI_BUILD_TRIGGERED**
| all | 0.5 | The flag to indicate that build was [triggered] |
|
**CI_BUILD_TOKEN**
| all | 1.2 | Token used for authenticating with the GitLab Container Registry |
|
**CI_PIPELINE_ID**
| 8.9 | 0.5 | The unique id of the current pipeline that GitLab CI uses internally |
|
**CI_PROJECT_ID**
| all | all | The unique id of the current project that GitLab CI uses internally |
|
**CI_PROJECT_NAME**
| 8.9 | 0.5 | The project name that is currently build |
|
**CI_PROJECT_NAMESPACE**
| 8.9 | 0.5 | The project namespace that is currently build |
|
**CI_PROJECT_PATH**
| 8.9 | 0.5 | The namespace with project name |
|
**CI_PROJECT_URL**
| 8.9 | 0.5 | The HTTP address to access project |
|
**CI_PROJECT_DIR**
| all | all | The full path where the repository is cloned and where the build is ran |
|
**CI_REGISTRY**
| 8.9 | 0.5 | If the Container Registry is enabled it returns address of GitLab's Container Registry |
|
**CI_REGISTRY_IMAGE**
| 8.9 | 0.5 | If the Container Registry is for project it returns the address of registry tied to specific project |
**Some of the variables are only available when using runner with at least defined version.**
...
...
@@ -46,18 +53,25 @@ Example values:
export
CI_BUILD_ID
=
"50"
export
CI_BUILD_REF
=
"1ecfd275763eff1d6b4844ea3168962458c9f27a"
export
CI_BUILD_REF_NAME
=
"master"
export
CI_BUILD_REPO
=
"https://gitlab.com/gitlab-org/gitlab-ce.git"
export
CI_BUILD_REPO
=
"https://git
ab-ci-token:abcde-1234ABCD5678ef@git
lab.com/gitlab-org/gitlab-ce.git"
export
CI_BUILD_TAG
=
"1.0.0"
export
CI_BUILD_NAME
=
"spec:other"
export
CI_BUILD_STAGE
=
"test"
export
CI_BUILD_TRIGGERED
=
"true"
export
CI_BUILD_TOKEN
=
"abcde-1234ABCD5678ef"
export
CI_P
ROJECT_DIR
=
"/builds/gitlab-org/gitlab-ce
"
export
CI_P
IPELINE_ID
=
"1000
"
export
CI_PROJECT_ID
=
"34"
export
CI_PROJECT_DIR
=
"/builds/gitlab-org/gitlab-ce"
export
CI_PROJECT_NAME
=
"gitlab-ce"
export
CI_PROJECT_NAMESPACE
=
"gitlab-org"
export
CI_PROJECT_PATH
=
"gitlab-org/gitlab-ce"
export
CI_PROJECT_URL
=
"https://gitlab.com/gitlab-org/gitlab-ce.git"
export
CI_REGISTRY
=
"registry.gitlab.com"
export
CI_REGISTRY_IMAGE
=
"registry.gitlab.com/gitlab-org/gitlab-ce"
export
CI_SERVER
=
"yes"
export
CI_SERVER_NAME
=
"GitLab
CI
"
export
CI_SERVER_REVISION
=
""
export
CI_SERVER_VERSION
=
""
export
CI_SERVER_NAME
=
"GitLab"
export
CI_SERVER_REVISION
=
"
8.9.0
"
export
CI_SERVER_VERSION
=
"
70606bf
"
```
### YAML-defined variables
...
...
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