Commit f99cb512 authored by priyaranjan.dr's avatar priyaranjan.dr

Update .gitlab-ci.yml

parent d2b2c337
Pipeline #11932 failed with stages
in 0 seconds
build-job: stages:
stage: build - publish
script: - deploy
- echo "Hello, $GITLAB_USER_LOGIN!"
test-job1: variables:
stage: test TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
script: TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
- echo "This job tests something"
test-job2: publish:
stage: test image: docker:latest
stage: publish
services:
- docker:dind
script: script:
- echo "This job tests something, but takes more time than test-job1." - docker build -t $TAG_COMMIT -t $TAG_LATEST .
- echo "After the echo commands complete, it runs the sleep command for 20 seconds" - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- echo "which simulates a test that runs 20 seconds longer than test-job1" - docker push $TAG_COMMIT
- sleep 20 - docker push $TAG_LATEST
deploy-prod: deploy:
image: alpine:latest
stage: deploy stage: deploy
tags:
- deployment
script: script:
- echo "This job deploys something from the $CI_COMMIT_BRANCH branch." - chmod og= $ID_RSA
\ No newline at end of file - apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker pull $TAG_COMMIT"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker container rm -f my-app || true"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker run -d -p 80:80 --name my-app $TAG_COMMIT"
environment:
name: production
url: http://your_server_IP
only:
- master
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment