Job templates begin with a dot to prevent execution
Templates can be imported using include
from…
.gitlab-ci.yml
See also the development guide for templates
Create inline tmplate:
.build-go:
script:
- |
go build \
-ldflags "-X main.Version=${CI_COMMIT_REF_NAME} -X 'main.Author=${AUTHOR}'" \
-o hello \
.
Use in build job
build:
extends: .build-go
# ...
Check pipeline
go.yaml
to root of projectInclude go.yaml
:
include:
- local: go.yaml
build:
extends: .build-go
# ...
go.yaml
from projecttemplate-go
go.yaml
to the root of the new projectInclude go.yaml
:
include:
- project: <GROUP>/template-go
ref: main
file: go.yaml