Skip to content
Snippets Groups Projects
Commit aee5c224 authored by ludo8147's avatar ludo8147
Browse files

define and run a pipeline

parent 644378e6
No related branches found
No related tags found
No related merge requests found
Pipeline #69215 passed
# Code aus Vorlesung
# https://docs.gitlab.com/ee/user/packages/container_registry/build_and_push_images.html
# https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
# https://docs.gitlab.com/ee/ci/services/
#Code: https://github.com/lucendio/lecture-devops-code/blob/master/tutorials/define-and-run-pipeline/.gitlab-ci.yml
# und Vorlesung
#https://docs.gitlab.com/ee/user/packages/container_registry/build_and_push_images.html
#https://docs.gitlab.com/ee/ci/yaml/workflow.html
workflow:
rules:
......@@ -9,7 +9,7 @@ workflow:
when: always
variables:
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest
version: 0.0.$CI_PIPELINE_IID
stages:
- 'build'
......@@ -23,38 +23,47 @@ job_test:
- go test -race -v ./...
job_build:
stage: build
image: mirror.gcr.io/library/golang:1.21
stage: 'build'
image: 'mirror.gcr.io/library/golang:1.21'
parallel:
matrix:
- GOOS:
- 'linux'
- 'windows'
- 'darwin'
GOARCH:
- 'amd64'
- 'arm64'
before_script:
- mkdir -p ./artifacts
script:
- go get -t ./...
- GOOS=linux GOARCH=amd64 CGO_ENABLED=0
go build
-o ./artifact.bin
script:
- |
go build \
-o ./artifacts/webservice_${GOOS}_${GOARCH}.bin \
./*.go
artifacts:
paths:
- ./artifact.bin
expire_in: 10 sec
- ./artifacts
job_upload:
stage: publish
image: registry.hub.docker.com/library/docker:24.0.7
job_publish:
stage: 'publish'
rules:
image: 'public.ecr.aws/lts/ubuntu:22.04'
tags:
- docker-privileged
dependencies:
- job_build
services:
- name: registry.hub.docker.com/library/docker:24.0.7-dind
before_script:
- apt update
- apt install -y ca-certificates curl
- update-ca-certificates
script:
echo ${CONTAINER_RELEASE_IMAGE}
- docker build
--file ./Containerfile
--tag "${CONTAINER_RELEASE_IMAGE}"
./
- docker push $CONTAINER_RELEASE_IMAGE
after_script:
- docker image rm --force "${CONTAINER_RELEASE_IMAGE}"
- |
for artifact in ./artifacts/*; do
chmod +x ${artifact}
curl \
--header "Job-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ${artifact} \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/artifacts/${version}/"
done
#Code: https://github.com/lucendio/lecture-devops-code/blob/master/tutorials/define-and-run-pipeline/.gitlab-ci.yml
# und Vorlesung
#https://docs.gitlab.com/ee/user/packages/container_registry/build_and_push_images.html
workflow:
rules:
......
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