Skip to content
Snippets Groups Projects

Tut01

Closed Yana Kernerman requested to merge s92604/devops-webservice:tut01 into main
2 files
+ 74
7
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 49
7
workflow:
rules:
- if: >-
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
when: 'always'
- when: 'never'
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push"
when: always
- when: never
stages:
- test
- build
- publish
job_trigger-pipeline:
trigger:
project: 'fb6-wp11-devops/webservice-build-and-publish'
job_test_the_code:
stage: test
image: registry.hub.docker.com/library/golang:1.21
script:
- go get -t ./...
- go test -race -v ./...
rules:
- when: always # Dieser Job läuft immer, unabhängig vom Branch oder Event.
job_build_artifact:
stage: build
image: registry.hub.docker.com/library/golang:1.21
script:
- go get -t ./...
- go build -o ./artifact.bin ./*.go
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
when: always # Build-Job läuft nur bei Push auf `main`.
artifacts:
paths:
- ./artifact.bin
expire_in: 1 week
job_publish_artifact:
stage: publish
image: curlimages/curl:latest
tags:
- docker-privileged
dependencies:
- job_build_artifact
script:
- echo "Publishing artifact..."
- env
- curl --version
- |
curl \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ./artifact.bin \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/artifacts/1.0.0/webservice"
rules:
- if: $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"
when: always # Publish-Job läuft nur bei Push auf `main
Loading