Skip to content
Snippets Groups Projects

Pipeline

Closed Gideon Bensch requested to merge s76867/webservice-devops:pipeline into main
1 file
+ 10
2
Compare changes
  • Side-by-side
  • Inline
+ 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:
workflow:
rules:
rules:
- if: >-
- if: >-
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
$CI_PIPELINE_SOURCE == "push"
when: 'always'
&& ($CI_COMMIT_BRANCH == "pipeline")
- when: 'never'
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:
run-job:
trigger:
stage: run
project: 'fb6-wp11-devops/webservice-build-and-publish'
image: mirror.gcr.io/library/golang:1.21
 
script:
 
- echo "running locally..."
 
- go run .
 
environment: production
 
\ No newline at end of file
Loading