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
0b2fc055
Commit
0b2fc055
authored
Feb 11, 2017
by
Dmitriy Volkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs(ci/docker_build): Add example of variable use
parent
8a1441fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
doc/ci/docker/using_docker_build.md
doc/ci/docker/using_docker_build.md
+24
-0
No files found.
doc/ci/docker/using_docker_build.md
View file @
0b2fc055
...
...
@@ -298,6 +298,30 @@ push to the Registry connected to your project. Its password is provided in the
`$CI_BUILD_TOKEN`
variable. This allows you to automate building and deployment
of your Docker images.
You can also make use of
[
other variables
](
../variables/README.md
)
to avoid hardcoding:
```
yaml
services
:
-
docker:dind
variables
:
IMAGE_TAG
:
$CI_REGISTRY_IMAGE:$CI_BUILD_REF_NAME
before_script
:
-
docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
build
:
stage
:
build
script
:
-
docker build -t $IMAGE_TAG .
-
docker push $IMAGE_TAG
```
Here,
`$CI_REGISTRY_IMAGE`
would be resolved to the address of the registry tied
to this project, and
`$CI_BUILD_REF_NAME`
would be resolved to the branch or
tag name for this particular job. We also declare our own variable,
`$IMAGE_TAG`
,
combining the two to save us some typing in the
`script`
section.
Here's a more elaborate example that splits up the tasks into 4 pipeline stages,
including two tests that run in parallel. The build is stored in the container
registry and used by subsequent stages, downloading the image
...
...
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