Created
September 6, 2017 07:36
-
-
Save mitchese/3647fdcd595ec41bcfe666e551d3af0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables: | |
DOCKER_DRIVER: overlay | |
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME | |
RELEASE_IMAGE: $CI_REGISTRY_IMAGE:latest | |
RANCHER_ACCESS_KEY: accesskey | |
RANCHER_SECRET_KEY: somelongkeygoeshere | |
RANCHER_URL: https://rancher.example.com/ | |
stages: | |
- build | |
- test | |
- release | |
- deploy | |
build_docker_image: | |
stage: build | |
image: docker:latest | |
services: | |
- docker:dind | |
tags: | |
- dind | |
script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
- docker build -t $IMAGE_TAG . | |
- docker push $IMAGE_TAG | |
unittest: | |
stage: test | |
services: | |
- docker:dind | |
tags: | |
- dind | |
script: | |
- docker run --rm $IMAGE_TAG test | |
#artifacts: | |
# when: on_failure | |
# expire_in: 1 week | |
release: | |
stage: release | |
tags: | |
- dind | |
script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
- docker pull $IMAGE_TAG | |
- docker tag $IMAGE_TAG $RELEASE_IMAGE | |
- docker push $RELEASE_IMAGE | |
only: | |
- master | |
deploy: | |
stage: deploy | |
image: cdrx/rancher-gitlab-deploy | |
script: | |
- docker run cdrx/rancher-gitlab-deploy:latest upgrade --stack ci-test --service helloworld --new-image $RELEASE_IMAGE --rancher-url $RANCHER_URL --rancher-secret $RANCHER_SECRET_KEY --rancher-key $RANCHER_ACCESS_KEY | |
tags: | |
- dind | |
only: | |
- master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment