Skip to content
Snippets Groups Projects

Pipeline

Closed Gideon Bensch requested to merge s76867/webservice-devops:pipeline into main
2 files
+ 46
6
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 44
6
# mostly from https://github.com/lucendio/lecture-devops-code/blob/911cb6dab66674aa71789568494a27dc58108491/exercises/define-and-run-pipeline/.gitlab-ci.yml#L46:L67
# Run pipeline if pushed to "pipeline" branch
workflow:
rules:
- if: >-
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
when: 'always'
- when: 'never'
$CI_PIPELINE_SOURCE == "push"
&& ($CI_COMMIT_BRANCH == "pipeline")
when: always
# Otherwise
- when: never
stages:
- test
- build
- run
test-job:
stage: test
image: mirror.gcr.io/library/golang:1.21
script:
- echo "running tests"
- go get -t ./...
- go test -race -v ./...
build-job:
stage: build
image: mirror.gcr.io/library/golang:1.21
before_script:
- mkdir -p ./artifacts
script:
- echo "installing dependencies..."
- go get -t ./...
- echo "building artifact..."
- go build -o ./artifacts/artifact.bin ./*.go
artifacts:
paths:
- ./artifacts
expire_in: 10 sec
job_trigger-pipeline:
trigger:
project: 'fb6-wp11-devops/webservice-build-and-publish'
run-job:
stage: run
image: mirror.gcr.io/library/golang:1.21
script:
- echo "running locally..."
- go run .
environment: production
\ No newline at end of file
Loading