Skip to content
Snippets Groups Projects

Tut01 test exercise

Closed Yana Kernerman requested to merge s92604/devops-webservice:tut01 into main
1 file
+ 10
3
Compare changes
  • Side-by-side
  • Inline
+ 10
3
@@ -32,16 +32,20 @@ job_build_artifact:
@@ -32,16 +32,20 @@ job_build_artifact:
- ./artifact.bin
- ./artifact.bin
expire_in: 1 week
expire_in: 1 week
job_publish_artifact:
job_build_and_publish_image:
stage: publish
stage: publish
rules: # Conditions under which this job should run
rules: # Conditions under which this job should run
- if: $CI_PIPELINE_SOURCE == "push" && $CI_MERGE_COMMIT_REF_NAME =~ /main/ # Run this job only for merge request event into main.
- if: $CI_PIPELINE_SOURCE == "push" && $CI_MERGE_COMMIT_REF_NAME =~ /main/ # Run this job only for merge request event into main.
when: always
when: always
image: curlimages/curl:latest # Custom image with curl
image: docker:24.0.0 # Official Docker image with Docker client installed
 
services:
 
- docker:24.0.0-dind # used to access the Docker daemon from within the CI job.
tags:
tags:
- docker-privileged
- docker-privileged
dependencies:
dependencies:
- job_build_artifact
- job_build_artifact
 
before_script:
 
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY" # Log in to the container registry
script:
script:
- echo "Publishing artifact..."
- echo "Publishing artifact..."
- ls -al # List files to confirm artifact.bin exists
- ls -al # List files to confirm artifact.bin exists
@@ -57,4 +61,7 @@ job_publish_artifact:
@@ -57,4 +61,7 @@ job_publish_artifact:
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
--upload-file ./artifact.bin \
--upload-file ./artifact.bin \
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/artifacts/1.0.0/webservice"
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/artifacts/1.0.0/webservice"
- docker build -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
 
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
 
after_script:
 
- docker rmi "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" # Clean up the image to free up space
Loading