Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
devops
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sauerburger-it
devops
Commits
51c4b6e2
Verified
Commit
51c4b6e2
authored
1 year ago
by
Frank Sauerburger
Browse files
Options
Downloads
Patches
Plain Diff
Refactor to use job templates
parent
4f6ce4a8
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+18
-14
18 additions, 14 deletions
README.md
templates/buildx-retag.yml
+1
-1
1 addition, 1 deletion
templates/buildx-retag.yml
templates/kaniko-build.yml
+1
-1
1 addition, 1 deletion
templates/kaniko-build.yml
with
20 additions
and
16 deletions
README.md
+
18
−
14
View file @
51c4b6e2
...
...
@@ -3,8 +3,10 @@ Test repository to experiment with GitLab [CI components](https://docs.gitlab.co
[TOC]
## General tips
*
Use the
`name`
argument to use a component multiple times in a single CI/CD pipeline
*
Use a
`name`
stating with a dot and extend the job if you need more customization
*
The jobs in this CI component are job templates. This means, by default, all job names start with a dot.
This approach has two advantages: you can use the job to instantiate multiple jobs from the same template using
`extends`
,
placing conditions on jobs becomes easier and avoids cases when no job is scheduled.
*
Use the
`name`
argument to use a component directly without
`extends`
## Components
...
...
@@ -20,7 +22,7 @@ The `kaniko-build` CI/CD component provides a template to build Docker images wi
|
`image_repo`
| Name of the Docker repository including the registry path |
`string`
|
`$CI_REGISTRY_IMAGE`
|
|
`image_tag`
| Tag of the Docker image |
`string`
|
`$CI_COMMIT_TAG`
|
|
`stage`
| Stage of the CI/CD job |
`string`
|
`build`
|
|
`name`
| Name of the CI/CD job |
`string`
|
`
docker
-build`
|
|
`name`
| Name of the CI/CD job |
`string`
|
`
.kaniko
-build`
|
|
`kaniko_tag`
| Kaniko docker image tag. THe job needs debug variants of Kaniko. |
`string`
|
`v1.20.1-debug`
|
|
`registry`
| Hostname (and port) of the Docker registry to which the job logs in |
`string`
|
`$CI_REGISTRY`
|
|
`registry_user`
| Username to authenticate with the Docker registry |
`string`
|
`$CI_REGISTRY_USER`
|
...
...
@@ -34,14 +36,12 @@ stages:
include
:
-
component
:
gitlab.sauerburger.com/sauerburger-it/devops/kaniko-build@0.1.0
rules
:
-
if
:
$CI_COMMIT_TAG
-
component
:
gitlab.sauerburger.com/sauerburger-it/devops/kaniko-build@0.1.0
rules
:
-
if
:
$CI_COMMIT_TAG
i
nputs
:
name
:
second-image
# Overwrite image name to allow multiple jobs
docker-build
:
extends
:
.kaniko-build
rules
:
-
i
f
:
$CI_COMMIT_TAG
```
### Docker image retag
...
...
@@ -56,7 +56,7 @@ operation doesn't require the job to download the image artifacts.
|
`source`
| Repository and tag of the existing source Docker image. |
`string`
|
`$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG`
|
|
`target`
| Repository and tag of the Docker image to push. |
`string`
|
`$CI_REGISTRY_IAMGE:latest`
|
|
`stage`
| Stage of the CI/CD job |
`string`
|
`deploy`
|
|
`name`
| Name of the CI/CD job |
`string`
|
`buildx-retag`
|
|
`name`
| Name of the CI/CD job |
`string`
|
`
.
buildx-retag`
|
|
`docker_tag`
| "Docker" Docker image tag. |
`string`
|
`25.0.3-cli`
|
|
`registry`
| Hostname (and port) of the Docker registry to which the job logs in |
`string`
|
`$CI_REGISTRY`
|
|
`registry_user`
| Username to authenticate with the Docker registry |
`string`
|
`$CI_REGISTRY_USER`
|
...
...
@@ -70,6 +70,10 @@ stages:
include
:
-
component
:
gitlab.sauerburger.com/sauerburger-it/devops/buildx-retag@0.1.0
rules
:
-
if
:
$CI_COMMIT_TAG
when
:
manual
tag-latest
:
extends
:
.buildx-retag
rules
:
-
if
:
$CI_COMMIT_TAG
when
:
manual
```
\ No newline at end of file
This diff is collapsed.
Click to expand it.
templates/buildx-retag.yml
+
1
−
1
View file @
51c4b6e2
...
...
@@ -5,7 +5,7 @@ spec:
stage
:
default
:
deploy
name
:
default
:
docker-build
default
:
.buildx-retag
docker_tag
:
default
:
"
25.0.3-cli"
registry
:
...
...
This diff is collapsed.
Click to expand it.
templates/kaniko-build.yml
+
1
−
1
View file @
51c4b6e2
...
...
@@ -5,7 +5,7 @@ spec:
stage
:
default
:
build
name
:
default
:
docker
-build
default
:
.kaniko
-build
kaniko_tag
:
default
:
"
v1.20.1-debug"
registry
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment