GitLab + Octopus CLI + Docker in Docker (image octopusdeploy/octo)

Octopus has 4 main steps that you should familiarize yourself with: 

- pack (creates package from source directory)

- push (pushes package to Octopus server)

- create-release (Octopus release contain one or more packages)

- deploy-release (Tells octopus to deploy release to target environments)

Here is an example of the .gitlab-ci.yml file defined in the GitLab project that works with octopusdeploy/octo docker image.

variables:
VERSION: "1.0.$CI_PIPELINE_IID"
DOCKER_TLS_CERTDIR: "/certs"
stages:
#- test
#- build
#- release
- create-release
- deploy-release
create-release:
image: docker:19.03.12
services:

- docker:19.03.12-dind
stage:
create-release
script:
- echo $(pwd)
- docker run --rm octopusdeploy/octo version
- docker run --rm -v $(pwd):/src octopusdeploy/octo pack --id="$OCTOPUS_PACKAGE_NAME" --version="$VERSION" --basePath="release/"
- docker run --rm -v $(pwd):/src octopusdeploy/octo push --package "$OCTOPUS_PACKAGE_NAME.$VERSION.nupkg" --server="$OCTOPUS_URL" --apiKey="$OCTOPUS_API_KEY" --space="$OCTOPUS_SPACE" --replace-existing --ignoreSslErrors
- docker run --rm -v $(pwd):/src octopusdeploy/octo create-release --project "$OCTOPUS_PROJECT_NAME" --version="$VERSION" --server="$OCTOPUS_URL" --apiKey="$OCTOPUS_API_KEY" --space="$OCTOPUS_SPACE" --ignoreSslErrors



deploy-release:
image: docker:19.03.12
services:

- docker:19.03.12-dind
stage:
deploy-release
script:
- docker run --rm -v $(pwd):/src octopusdeploy/octo deploy-release --project "$OCTOPUS_PROJECT_NAME" --version="$VERSION" --server="$OCTOPUS_URL" --apiKey="$OCTOPUS_API_KEY" --space="$OCTOPUS_SPACE" --progress --waitForDeployment --deployto=$OCTOPUS_DEPLOYTO_ENV --ignoreSslErrors
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: always
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
when: manual






Please have a look how to setup local GitLab runner to support Docker in Docker:

https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled

Comments

Popular posts from this blog

UML Sequence Diagram and Visual Studio