Skip to content

Instantly share code, notes, and snippets.

@mcclory
Created May 10, 2017 15:52
Show Gist options
  • Save mcclory/4fed558d846d5f84070406faffd12c6c to your computer and use it in GitHub Desktop.
Save mcclory/4fed558d846d5f84070406faffd12c6c to your computer and use it in GitHub Desktop.
Sample .gitlab-ci.yml files for CloudExpo Asia Hong Kong talk
stages:
- pre-flight
- resolve-dependencies
- compile
- unit-test
- package
- deployment-test
- functional-test
- publish
before_script:
- if [ "$CI_JOB_STAGE" == "publish" ]; then docker pull $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA; fi
after_script:
- docker rmi --force $(docker images -aq $REPOSITORY_NAME/$IMAGE_NAME)
variables:
REPOSITORY_NAME: docker.trebuchetdev.com
IMAGE_NAME: gnatsd
GNATSD_VERSION: v0.9.6
GNATSD_DOWNLOAD_URL: https://github.com/nats-io/gnatsd/releases/download
GNATSD_SRC_SHA256: 71f9c10bf3655612433f62de70e5e5261e8c881166a603842fd06bfd59c13291
STABLE_TAG_NAME: stable
buildImage:
stage: package
script:
- docker build --build-arg GNATSD_VERSION=$GNATSD_VERSION --build-arg GNATSD_DOWNLOAD_URL=$GNATSD_DOWNLOAD_URL --build-arg GNATSD_SRC_SHA256=$GNATSD_SRC_SHA256 --tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA .
- docker push $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA
smokeTest:
stage: functional-test
script:
- docker run $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA version
publishLatest:
stage: publish
script:
- docker tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA $REPOSITORY_NAME/$IMAGE_NAME:latest
- docker push $REPOSITORY_NAME/$IMAGE_NAME:latest
only:
- master@platform-dockerfiles/nats
publishTagVersion:
stage: publish
script:
- docker tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_REF_NAME
- docker push $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_REF_NAME:$CI_COMMIT_REF_NAME
only:
- tags@platform-dockerfiles/nats
publishStableTag:
stage: publish
when: manual
script:
- docker tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA $REPOSITORY_NAME/$IMAGE_NAME:$STABLE_TAG_NAME
- docker push $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_REF_NAME:$STABLE_TAG_NAME
only:
- tags@platform-dockerfiles/nats
stages:
- pre-flight
- resolve-dependencies
- compile
- unit-test
- package
- deployment-test
- functional-test
- publish
before_script:
- if [ "$CI_JOB_STAGE" == "publish" ]; then docker pull $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA; fi
after_script:
- docker rmi --force $(docker images -aq $REPOSITORY_NAME/$IMAGE_NAME)
variables:
REPOSITORY_NAME: docker.trebuchetdev.com
IMAGE_NAME: terraform
VERSION: 0.9.4
buildImage:
stage: package
script:
- docker build --build-arg TF_VERSION=$VERSION --tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA .
- docker push $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA
publishLatest:
stage: publish
script:
- docker tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA $REPOSITORY_NAME/$IMAGE_NAME:latest
- docker push $REPOSITORY_NAME/$IMAGE_NAME:latest
only:
- master@platform-dockerfiles/terraform
publishTagVersion:
stage: publish
script:
- docker tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_REF_NAME
- docker push $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_REF_NAME
only:
- tags@platform-dockerfiles/terraform
publishStableTag:
stage: publish
when: manual
variables:
STABLE_TAG_NAME: stable
script:
- docker tag $REPOSITORY_NAME/$IMAGE_NAME:$CI_COMMIT_SHA $REPOSITORY_NAME/$IMAGE_NAME:$STABLE_TAG_NAME
- docker push $REPOSITORY_NAME/$IMAGE_NAME:$STABLE_TAG_NAME
only:
- tags@platform-dockerfiles/terraform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment