Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
devops-webservice
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yana Kernerman
devops-webservice
Merge requests
!10
testing tut04
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
testing tut04
tut04
into
main
Overview
0
Commits
4
Pipelines
1
Changes
2
Open
Yana Kernerman
requested to merge
tut04
into
main
4 months ago
Overview
0
Commits
4
Pipelines
1
Changes
2
Expand
0
0
Merge request reports
Compare
main
main (HEAD)
and
latest version
latest version
e4b20fd6
4 commits,
4 months ago
2 files
+
15
−
43
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
.gitlab-ci.yml
+
15
−
37
Options
workflow
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
when
:
always
-
if
:
$CI_PIPELINE_SOURCE == "push"
when
:
always
-
when
:
never
when
:
'
always'
-
if
:
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME =~/main/
-
when
:
'
never'
stages
:
-
test
-
build
-
publish
job_test_the_code
:
@@ -17,41 +15,21 @@ job_test_the_code:
script
:
-
go get -t ./...
-
go test -race -v ./...
rules
:
-
when
:
always
job_build_artifact
:
stage
:
build
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME =~ /main/
when
:
always
image
:
registry.hub.docker.com/library/golang:1.21
script
:
-
go get -t ./...
-
go build -o ./artifact.bin ./*.go
artifacts
:
paths
:
-
./artifact.bin
expire_in
:
1 week
job_publish_artifact
:
job_build_and_publish_image
:
stage
:
publish
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_REF_NAME =~ /main/
when
:
always
image
:
curlimages/curl:latest
image
:
docker:24.0.0
services
:
-
docker:24.0.0-dind
tags
:
-
docker-privileged
dependencies
:
-
job_build_artifact
before_script
:
-
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script
:
-
echo "Publishing artifact..."
-
echo "Publishing artifact
..."
-
ls -al
-
pwd
-
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"
-
TAG=$CI_COMMIT_REF_SLUG
-
docker build --file ./Dockerfile --tag "$CI_REGISTRY_IMAGE:$TAG" .
-
docker push "$CI_REGISTRY_IMAGE:$TAG"
\ No newline at end of file
Loading