Skip to content
Snippets Groups Projects
Verified Commit 51c4b6e2 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Refactor to use job templates

parent 4f6ce4a8
No related branches found
No related tags found
No related merge requests found
......@@ -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
inputs:
name: second-image # Overwrite image name to allow multiple jobs
docker-build:
extends: .kaniko-build
rules:
- if: $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
......@@ -5,7 +5,7 @@ spec:
stage:
default: deploy
name:
default: docker-build
default: .buildx-retag
docker_tag:
default: "25.0.3-cli"
registry:
......
......@@ -5,7 +5,7 @@ spec:
stage:
default: build
name:
default: docker-build
default: .kaniko-build
kaniko_tag:
default: "v1.20.1-debug"
registry:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment