Reference Guide

Continuous Delivery Automation Framework features are opinionated and configuration driven. See the introduction material for step-by-step guidance.

Subsections of Reference Guide

Framework Implementation

CDAF Core Component Specifications

This section provides a detailed breakdown of the Continuous Delivery Automation Framework (CDAF) itself.

Subsections of Framework Implementation

Entry Points

CDAF Entry Scripts

CDAF providers 4 entry scripts for different purposes.

  • ci : Build and Package only, i.e. Continuous Integration, mandatory argument is BUILDNUMBER
  • cd : Release, i.e. Continuous Delivery or Deploy (depending on gating or not), mandatory argument is ENVIRONMENT
  • cdEmulate : Executes ci and then cd, generates BUILDNUMBER if not supplied and uses configurable ENVIRONMENT
  • entry : Executes ci and then cd, generates BUILDNUMBER if not supplied and uses configurable ENVIRONMENT(s)

The CI entry point (ci.bat/ci.sh) will perform the build and package process. Recommended configuration is to produce a self extracting deployable artefact (release.ps1/release.sh).

sequenceDiagram
  ci ->>+ buildPackage: BUILDNUMBER
  buildPackage ->>- ci: release

CD Emulation

The CD Emulation (cdEmulate.bat/cdEmulate.sh) is a simple wrapper which performs the CI process, and then executes the CD process, using the configured or default environment.

sequenceDiagram
  cdEmulate ->>+ buildPackage: BUILDNUMBER
  buildPackage ->>- cdEmulate: release
  cdEmulate ->>+ release: ENVIRONMENT
  release ->>- cdEmulate: deployment results

Entry

The entry wrapper (entry.bat/entry.sh), similar to cdEmulate, performs the CI process and CD process. The CD process however supports additional, optional, configuration for releases based on branch name (substrings).

sequenceDiagram
  cdEmulate ->>+ buildPackage: BUILDNUMBER
  buildPackage ->>- cdEmulate: release
  loop for each matching branch name
    cdEmulate ->>+ release: ENVIRONMENT
    release ->>- cdEmulate: deployment results
  end

Task Processing

Execution Engine

The CDAF execution engine allows the DevOps Engineer to focus on the primary objective, and not have to cater for logging, exception and error handling. Within this engine are a set of operations for common problems, further allowing a focus on results and rewriting/copying scripts. See Execution Engine documentation.

Note: The following is details a subset of CDAF capabilities, describing a common usage, For a detailed breakdown of each component, see the CDAF Reference Guide.

sequenceDiagram
  autonumber
  participant entry point
  participant buildPackage
  participant buildProjects
  participant execute
  participant package

  entry point ->>+ buildPackage: BUILDNUMBER
    Note right of buildPackage: "Build" Process Begins
    buildPackage ->> buildPackage: Property Translation (properties.cm)
    loop for each Directory containering build.tsk
      Note right of buildPackage: "Project" is a historical name <br/> from Eclipse & Visual Studio
      buildPackage ->>+ buildProjects: Project Name
      buildProjects ->>+ Transform: Load Properties
      Transform ->>- buildProjects: propertyList
      buildProjects ->>+ execute: build.tsk
      loop for each Line in build.tsk
        Note right of execute: Build commands, such as <br/> MSBuild, NPM, etc.
        execute ->> execute: log, execute and manage errors
      end
      execute ->>- buildProjects: build artefacts
      buildProjects ->>- buildPackage: build complete
    end

    Note right of buildPackage: "Package" Process Begins
    buildPackage ->>+ package: proejctName
    package ->>+ Transform: Load Properties
    Transform ->>- package: propertyList
    package ->>- buildPackage: project complete
    buildPackage ->>+ packageLocal: prepare release
      packageLocal ->> packageLocal: Gather CDAF SCripts <br/> and deploy properties
      packageLocal ->> packageLocal: Gather user defined artefacts
    packageLocal ->>- buildPackage: artefacts
    buildPackage ->> buildPackage: generate self-extract release
  buildPackage ->>- entry point: release.ps1 or release.sh

Feature Configuration

Declarative Desired State Container Deployment using Helm

This section provides a detailed breakdown of the Continuous Delivery Automation Framework (CDAF) feature configuration options. For a step-by-step usage guide see getting started.

Subsections of Feature Configuration

Configuration Mapping

Configuration Mapping

The local and remote configuration will trigger a task execution based on each unique declaration of context and target, using the corresponding default task tasksRunLocal.tsk and tasksRunLocal.tsk.

context  target  deployHost
remote   UAT     vm.example.com
local    UAT     vm.example.com
remote   PROD    vm.example.com
local    PROD    vm.example.com

Customer tasks can be defined for directories customLocal and customRemote respectively, or custom if shared.

context    target  deployTaskOverride
local      DOCKER  docker-compose-test.tsk
remote     UAT     on-premise-deploy.tsk
remote     PROD    on-premise-deploy.tsk
container  PUSH    publish-production-ertefact.tsk

Note that container override tasks are made available in the customRemote directory.

Execution Engine

Execution Engine

To alleviate the burden of argument passing, exception handling and logging, the execution engine has been provided. The execution engine will essentially execute the native interpretive language (PowerShell or bash), line by line, but each execution will be tested for exceptions (trivial in bash, significantly more complex in PowerShell).

Where is it used

In all places using .tsk files, i.e. build, package, wrap and deploy. The following operations are available to all tasks, however, some are more applicable to specific processes, see Build, Local and Remote task execution for more details of how these can be used.

Operations

The following operations are provided to simplify common tasks.

Keyword Description Example
ASSIGN Display, and expand as necessary, variable assignment ASSIGN $test="$varcontainingvar"
CMPRSS Compress directory to file CMPRSS packageName dirName
DCMPRS Decompress package file DCMPRS packageName
DECRYP decrypt using private key (PKI) DECRYP crypt/encrypt.dat
   decrypt using AES/GPG key DECRYP crypt/encrypt.dat $key
DETOKN Detokenise file with target prop DETOKN token.yml
   Detokenise with specific file DETOKN token.yml PROP_FILE
   Detokenise with encrypted file DETOKN token.yml crypt/FIL $key
   Expand and reveal embedded variables and detokenise DETOKN token.yml $TARGET reveal
   Expand but do not reveal embedded variables and detokenise DETOKN token.yml manifest.txt resolve
EXCREM Execute command EXCREM hostname
   Execute script EXCREM ./capabilities.sh
EXERTY Execute Retry, wait 10 seconds and retry twice EXERTY “temperamentalcommand”
   Optional, wait and retry override EXERTY “verytemperamentalcommand” 20 5
EXITIF Exit normally if argument set EXITIF $ACTION
   Exit normally if set to value EXITIF $ACTION clean
IGNORE Execute expression, log and ignore errors IGNORE “command arg1 arg2”
IMGTXT Display image file as text (wrapper for jp2a in Linux) IMGTXT sample.jpg
INVOKE call a custom script INVOKE ./script “Hello”
MAKDIR Create a directory and path (opt) MAKDIR directory/and/path
MASKED Return an uppercase hexadecimal checksum using SHA256 MASKED $password
MD5MSK Deprecated. Return an uppercase hexadecimal checksum MD5MSK $password
PROPLD Load properties as variables PROPLD PROP_FILE
   Expand and reveal embedded variables PROPLD $TARGET reveal
   Expand but do not reveal embedded variables PROPLD manifest.txt resolve
REFRSH Refresh directory contents REFRSH manifest.txt ~/temp_dir
   clear directory contents (create if not existing) REFRSH ~/temp_dir
REMOVE Delete files, including wildcard REMOVE *.war
REPLAC Replace token in file REPLAC fileName %token% $value
VARCHK Variable validation using default file properties.varchk VARCHK
   Variable validation using names file VARCHK vars.properties
VECOPY Verbose copy VECOPY *.war

Notes on EXCREM use, the properties are similar to those used for remote tasks, where the minimum required is the host, if other properties are not used, must be set to NOT_SUPPLIED, i.e.

deployHost=localhost
remUser=NOT_SUPPLIED
remCred=NOT_SUPPLIED
remThb=NOT_SUPPLIED

Windows only

The following operations are only available in PowerShell version

Keyword Description Example
CMDTST Returns true if command exists CMDTST vagrant
ELEVAT Execute as elevated NT SYSTEM ELEVAT “$(pwd)/custom.ps1”
EXECMD Execute in Command (CMD) shell ELEVAT “terraform $OPT_ARG”
MSTOOL Microsoft Build Tools, set environment variables
• MS_BUILD
• MS_TEST
• VS_TEST
• DEV_ENV
• NUGET_PATH
MSTOOL

Common Variables

These are automatically set at both build and deploy time.

Variable Description
$SOLUTIONROOT The solution directory identified by localtion of CDAF.solution file
$SOLUTION The solution name identified by property in CDAF.solution file
$BUILDNUMBER The first argument passed for CI, and propagated to CD
$CDAF_CORE Core CDAF runtime location
$TASK_NAME The name of the task file currently executing
$TARGET Available in both build and deploy, but derived differently, see below for details

Build-time Variables

These are automatically set at execution start-up

Variable Description
$AUTOMATIONROOT The installation directory of the Continuous Delivery Automation Framework
$ACTION The second argument passed, has some hardcoded functions
• clean: only remove temp files
• packageonly: skip any build tasks
$TARGET At build time, this is derived (Can be overridden, see CDAF_BUILD_ENV environment variable)
• Linux: Set to WSL for Windows Subsystem, otherwise LINUX
• Windows: Set to WINDOWS is on-domain, otherwise WORKGROUP
$TMPDIR Automatically set to the temp dir
$WORKSPACE The working directory at execution start-up

See also Environment and Global Variables.

Deploy-time Variables

Variable Description
$ENVIRONMENT This is the first argument passed to the release, the targets are derived from this
$TARGET All targets are processed based on pattern match $ENVIRONMENT*, the TARGET being currently executed is set in this variable
$RELEASE Second argument passed to release
$OPT_ARG Third argument passed to release

Environment Variables

Environment Variables

Due to inconsistencies between Windows and Linux handling of environment variables, these have been divided between environment variables that are set before calling an entry script to alter the behaviour of CDAF, and environment variables that are set within bash scripts to make them globally available.

Control Variables

The following environment variables are available to control the behaviour of CDAF

Variable Description
CDAF_BRANCH_NAME Used by entry.ps1/entry.sh
Override the branch name, primarily to test CI behaviour for non-default branch, i.e. main
CDAF_BUILD_ENV Define the build environment, if not set, defaults will be used, see execution engine Build-time Variables for details
CDAF_CB_{variable_name} Prefix used in containerBuild to supply local variables into the build time container
CDAF_CD_{variable_name} Prefix used in containerDeploy to supply local variables into the deploy time container
CDAF_IB_{variable_name} Prefix used in containerBuild to supply during image construction
CDAF_OPT_{any_value} Prefix used in containerDeploy to set docker run options e.g. $env:CDAF_OPT_foo = ‘–cpu-count 2’ $env:CDAF_OPT_bar = ‘–label custom=release’
CDAF_DOCKER_REQUIRED containerBuild will attempt to start Docker if not running and will fail if it cannot, rather than falling back to native execution
CDAF_DOCKER_RUN_ARGS containerBuild additional run arguments, e.g. ‘–memory=2048m’
CDAF_DELIVERY The default target environment for cdEmulate and entry, defaults are
LINUX, or
WINDOWS for on-domain or WORKGROUP for off-domain
CDAF_ERROR_DIAG Dependency injected custom call if error occurs in Execution Engine
CDAF_HOME_MOUNT to disable volume mount for containerDeploy set to ’no’, note: this can be overridden a solution level, using CDAF_HOME_MOUNT as property
CDAF_IGNORE_WARNING If messages are logged to standard error, the Execution Engine will log but not halt, however is this is set to yes, processing will halt
yes or no, default is yes
CDAF_LOG_LEVEL Set to DEBUG for verbose logging
CDAF_OVERRIDE_TOKEN Default marker for DETOKN or PROPLD in Execution Engine is %, i.e. %key_name%, the markers can be changed using this environment variable
CDAF_SKIP_CONTAINER_BUILD containerBuild will not be performed if this environment variable is set to any value
CONTAINER_IMAGE Override containerImage in containerBuild & imageBuild

Global Variables

These variables are available to child scripts, custom scripts and task execution engine, see also Build-time Variables.

Variable Description
CDAF_CORE CDAF helper script path
WORKSPACE_ROOT Static for solution, WORKSPACE will change for project (build) or target (deploy)

See also Build-time Variables.

Image Registry

These override Solution Properties properties. They are used to push the image created by dockerBuild to pull a base image from a private registry.

Variable Description
CDAF_SKIP_PULL Skip updating of image
CDAF_PULL_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_PULL_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_PULL_REGISTRY_TOKEN Registry token, example xyzx9234sxsrwcqw34

These override Solution Properties properties. They are used to push the image created by imageBuild to push to a private registry.

Variable Description
CDAF_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_REGISTRY_TAG Image tag(s), can being single value latest or list latest ${BUILDNUMBER}
CDAF_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_REGISTRY_TOKEN Registry token, example xyzx9234sxsrwcqw34

These override Solution Properties properties. They are used to push the image created by dockerPush to push to a private registry.

Variable Description
CDAF_PUSH_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_PUSH_REGISTRY_TAG Image tag(s), can being single value latest or list latest ${BUILDNUMBER} (default is latest)
CDAF_PUSH_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_PUSH_REGISTRY_TOKEN Registry token, example xyzx9234sxsrwcqw34

Solution Properties

Solution Properties

CDAF.solution : file to identify a directory as the automation solution directory where the key configuration files are placed. This file is used as the bases of the manifest.txt file while is included in the resulting CI artefact package.

See solution/CDAF.solution in CDAF automation directory.

Solution Properties

Variable Description
solutionName Required. Do not include spaces.
productName Solution description, this can contain spaces.
artifactPrefix Generate a self-extracting package script, example 0.0, mutually exclusive to productVersion
productVersion Do a self-extracting package script, example 0.0.0
containerBuild Dependency injection for running container based build execution
containerImage Image to be used in the container based build execution
containerDeploy Execute deployment from within a container, uses the storeForRemote artefact definition
imageBuild Dependency injection for creating a container image after CI process, see the Image Registry properties below
runtimeImage Image to used in the runtime image created by imageBuild
constructor Directory in which container images are constructed, default action will traverse and build in all directories
defaultBranch Used to determine feature branch functionality, default is master
defaultEnvironment Default environment to use for CDAF Feature Branch Environments post, defaults to DOCKER
processSequence Deployment Process Sequence, defaults to localTasks, remoteTasks and finally containerTasks

Environment Variable Substitution

The following properties can be used in place of environment variables

Variable Description
CDAF_HOME_MOUNT to disable volume mount for containerDeploy set to ’no'
CDAF_ERROR_DIAG Dependency injected custom call if error occurs in Execution Engine
CDAF_DOCKER_REQUIRED containerBuild will attempt to start Docker if not running and will fail if it cannot, rather than falling back to native execution

Image Registry

These properties are used to push the image created by dockerBuild to pull a base image from a private registry. These can be overriden by Environment Variables.

Variable Description
CDAF_SKIP_PULL Skip updating of image
CDAF_PULL_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_PULL_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_PULL_REGISTRY_TOKEN Registry token, example xyzx9234sxsrwcqw34

These properties are used to push the image created by imageBuild to push to a private registry. These can be overriden by Environment Variables.

Variable Description
CDAF_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_REGISTRY_TAG Image tag(s), can be a single value latest (default) or space separated list, e.g. latest ${BUILDNUMBER}
CDAF_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_REGISTRY_TOKEN Registry authentication token

These properties are used to push the image created by dockerPush to push to a private registry. These can be overriden by Environment Variables.

Variable Description
CDAF_PUSH_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_PUSH_REGISTRY_TAG Image tag(s), can be a single value latest (default) or space separated list, e.g. latest ${BUILDNUMBER}
CDAF_PUSH_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_PUSH_REGISTRY_TOKEN Registry authentication token

Git Clean-up Properties

To clean-up Git branches and docker images, the following properties are used.

Variable Description
gitRemoteURL https://gitserver.local/mysolution.git
gitUserNameEnvVar gituser
gitUserPassEnvVar secret-pat
gitCustomCleanup & $AUTOMATIONROOT/buildandpackage/clean.ps1 or $AUTOMATIONROOT/buildandpackage/clean.sh

Extended Processes

Extended Processes

Optional Build Processes

By placing these files in your solution root, the processes will execute as described

File Name Description
prebuild.tsk Execute after Configuration Management processing, but before any build tasks
postbuild.tsk Execute after solution and project level build tasks are complete

Optional Package Processes

By placing these files in your solution root, the processes will execute as described

File Name Description
package.tsk Execute after package workspace has been cleaned
wrap.tsk Execute after package but prior to creating self-extracting release

Feature Branch Execution

Feature Branch Execution

Place feature-branch.properties in your SOLUTIONROOT to allow dynamic delivery execution, based on Git Branch name. This capability is limited to entry.sh/entry.bat/entry.ps1, which are Git aware, and the recommended loose coupling entry scripts for CDAF.

# Separate environments for features and bugs
feature=DEV1
bugfix=DEV2

# Hotfixes deploy to all environments
hotfix=DEV1
hotfix=DEV2

See CDAF Samples for complete implementations in Linux and Windows.

Sensitive Data Strategies

Sensitive Data Strategies

Loose Coupling

A key approach to support the principle of automation execution in a local desktop context, is the use of environment variables. It’s important to remember that environment variables do not necessarily need to be persisted, i.e. stored unencrypted on disk, it’s the global availability of the variable that makes it an environment variable.

context  target  databaseFQDN        dBpassword
local    TEST    db1.nonprod.local   $DB1_PASSWORD
local    UAT     db2.nonprod.local   $DB2_PASSWORD
local    PROD    cluster.prod.local  $PRD_PASSWORD

Variable Expansion

Variables can be referenced in preoperties files (see [Configuration Management][mydoc_basics_configuration_management]) or CDAF.solution file and then expanded at deploy time into variables or files using ASSIGN, PROPLD or DETOKN in the execution engine.

Encrypted Files

This approach is to allow secrets in a file to be stored in source control. Encryption key for Windows is an EAS key, while for Linux it’s a GPG key. This approach is used when there are a large number of secrets to cater for, and therefore only the key needs to be managed as a secret.

In early generations of secret management, the secrets would be stored as persistent environment variables, however all modern toolsets provide an encrypted store which can load secrets as environment variables.

See the DECRYP & DETOKN operations in the execution engine for guidance on usage.

Cloud Storage Integration

Toolset providers who also supply public cloud provide integration to their secret storage offerings, while these can be convenient, this does couple your automation to toolset and makes the execution of locally challenging.

Legacy Features

Legacy Features

Remote Deployment

Machine to machine deployments are increasingly uncommon, as local agents/runners are readily available, making on-premise deployments from the build server an infrequent use case. While there is no plan to deprecate this capability, it’s complexity makes local testing i.e. shift-left complicated, especially in windows. For CDAF configuration, see Remote Tasks.

Windows Remote PowerShell

This approach uses the local host for both target (CD) and build (CI) execution. Provision the host with both roles

.\automation\provisioning\mkdir.ps1 C:\deploy
.\automation\provisioning\CredSSP.ps1 server

.\automation\provisioning\trustedHosts.ps1 *
.\automation\provisioning\CredSSP.ps1 client

Linux SSH

Generate PKI key and public certificate, and perform a loop-back connection to local host to place the public certificate in the authorised hosts configuration.

.\automation\provisioning\agent.sh deployer@localhost

Symetric Encryption

With the implementation of 12-Factor applications, secret management in files is less common, and the storage of encrypted files in source control for subsequent decryption is now uncommon. While this capability is not planned for deprecation, it is recommended to use sensitive data strategies instead.

Variable Validation

Variable Validation

There are 5 rules available, two for plain text and three for secrets. When validating a secret against a known MD5 value, either a literal or variable can be supplied. See VARCHK in the execution engine operations

# Plain text values
OPT_ARG                                # Optional plain text
terraform_version=required             # Required plain text

# Secret values
TERRAFORM_TOKEN=optional               # Optional secret
TERRAFORM_TOKEN=secret                 # Required secret
TERRAFORM_TOKEN=$TERRAFORM_TOKEN_MASK  # Required secret verified against supplied SHA-256 value

Docker Features

Container Exploitation and Image Building

These features provide opinionated wrappers for using docker to perform the following:

  • containerBuild : to execute build processes in a pre-provisioned, or custom provisioned container
  • imageBuild : to create images for publication
  • containerDeploy : to execute deployment processes in a pre-provisioned, or custom provisioned container

Pre-provisioned images are available in DockerHub.

Subsections of Docker Features

containerBuild

containerBuild

Some CI/CD pipeline toolsets support native capability (GitLab, BitBucket) to execute with a container. In other some cases, (CircleCI, Travis) all pipeline activity can only be executed within containers.

For toolsets which do not support this functionality, but do allow for self-hosted agents or where a self-hosted agent is preferred/mandated i.e. execution within a private network, the CDAF container helpers can provide consistency for construction, execution and housekeeping.

Even with a toolset uses containers, if they support docker-in-docker, the CDAF container helpers can still be utilised.

containerBuild

containerBuild

Master of Build Success

The containerBuild option allows the execution of the build process from within a container. Unlike toolsets which reference a image that is used to create the build container, CDAF uses a Dockerfile, for the following advantages:

  • Build Prerequisites can be defined in code, without being limited to available published images
  • Once constructed the image image cache provides improved performance, without having to use a image registry
  • Working directory and user home directory are volume mounted, to allow caching of build dependencies, e.g. Maven, node_modules

Container Build Configuration

To execute the build within a container, add the containerBuild definition and containerImage to CDAF.solution. Note: complete definitions are provided in the GitHub samples for Windows and Linux.

The following samples have the default process commented out, and can be used to define a custom process.

Windows

containerImage=cdaf/windows
# containerBuild=& ${AUTOMATIONROOT}/processor/containerBuild.ps1 $SOLUTION $BUILDNUMBER $REVISION $ACTION

Linux

containerImage=cdaf/linux
# containerBuild=$AUTOMATIONROOT/processor/containerBuild.sh $SOLUTION $BUILDNUMBER $REVISION $ACTION

Build Time Variables

To supply variables to the build process, prefix with CDAF_CB_ (see CDAF Environment Variables) and the variables will be mapped into the build container.

See GitHub samples for Windows and Linux for dockerfile and additional properties.

imageBuild

imageBuild

This helper script supports the creation of docker images, and conditionally, the pushing of that image to a registry.

Container Build Configuration

To execute, define the buildImage definition. Note: complete definitions are provided in the GitHub samples for Windows and Linux.

The following samples have the default process commented out, and can be used to define a custom process.

Windows

buildImage=cdaf/windows
# imageBuild=& "$AUTOMATIONROOT/remote/imageBuild.ps1" ${SOLUTION}_${REVISION} ${BUILDNUMBER}

Linux

buildImage=cdaf/linux
# imageBuild="$AUTOMATIONROOT/remote/imageBuild.sh" ${SOLUTION}_${REVISION} ${BUILDNUMBER}

Immutable Deploy in Construction

If a custom docker file is not supplied, the default dockerfile will execute the IMMUTABLE release in the image construction process.

Registry Push

To include a push to a registry, add the following to CDAF.solution for DockerHub

CDAF_REGISTRY_URL=DOCKER-HUB
CDAF_REGISTRY_TAG=repo/${SOLUTION}:$BUILDNUMBER
CDAF_REGISTRY_USER=pat
CDAF_REGISTRY_TOKEN=${ACCESS_TOKEN}

Or for another registry provider or a self-hosted registry

CDAF_REGISTRY_URL=myregistry.io/repo
CDAF_REGISTRY_TAG=${CDAF_REGISTRY_URL}/${SOLUTION}:$BUILDNUMBER
CDAF_REGISTRY_USER=pat
CDAF_REGISTRY_TOKEN=${ACCESS_TOKEN}

Custom Image & Process

For samples of more complex usage see the GitHub samples for Windows and Linux dockerfile and additional properties.

Stand-alone Usage

The imageBuild script is used for docker-compose stand-up/tear-down process, for complete samples see Windows and Linux.

The following parameters must be passed

  • Unique ID : normally "${SOLUTION}_${REVISION}"
  • Sequential Number : normally "${BUILDNUMBER}"
  • Base Image : any valid image, e.g. cdaf/linux or cdaf/windows

Optional parameters

  • Context : if supplied, only the named directory is built, if ommited, all directories are built.

containerDeploy

containerDeploy

Like containerBuild, containerDeploy provides both image build and container task execution. The common use for container deploy where a command line interface is required.

Master of Deployment Success

The containerDeploy option allows the execution of the deploy process from within a container. Unlike toolsets which reference a image that is used to create the deploy container, CDAF uses a Dockerfile, for the following advantages:

  • Deploy Prerequisites can be defined in code, without being limited to available published images
  • Once constructed the image image cache provides improved performance, without having to use a image registry

Container Deploy Configuration

To execute the deploy within a container, add the containerDeploy definition and runtimeImage (if not supplied, containerImage will be used) to CDAF.solution. Note: complete definitions are provided in the GitHub samples for Windows and Linux.

The following samples have the default process commented out, and can be used to define a custom process.

Windows

runtimeImage=cdaf/windows
# containerDeploy=& ${WORK_DIR_DEFAULT}/containerDeploy.ps1 "${TARGET}" "${RELEASE}" "${SOLUTION}" "${BUILDNUMBER}" "${REVISION}" -imageDir cli

Linux

containerImage=cdaf/linux
# containerDeploy=${WORK_DIR_DEFAULT}/containerDeploy.sh "${TARGET}" "${RELEASE}" "${SOLUTION}" "${BUILDNUMBER}" "${REVISION}" cli

Deploy Time Variables

To supply variables to the build process, prefix with CDAF_CD_ (see CDAF Environment Variables) and the variables will be mapped into the build container.

See GitHub samples for Windows and Linux for dockerfile and additional properties.

Custom Image

The default directory used for container deploy is containerDeploy, if this is not found, the default Dockerfile is used, with the default runtime files. If you have your own Dockerfile in containerDeploy, or a custom directory specified in CDAF.solution containerDeploy property, then that will be used.

Runtime Files

The release.sh file is included in the default image, however, if using a default image, this needs to be explicitly defined in CDAF.solution runtimeFiles property. This can be a space separated list of files.

runtimeFiles=$WORKSPACE_ROOT/release.sh

Runtime Retain

To skip image clean-up, set CDAF.solution runtimeRetain property.

runtimeRetain=yes

dockerPush

dockerPush

Using the same logic after imageBuild, this utility script provides simple login and push logic.

The script can be called passing arguments

./dockerPush.ps1 $TARGET_TAG cdaf/${SOLUTION} "${artifactPrefix}.${BUILDNUMBER} latest" $DOCKERHUB_TOKEN cdaf

This example uses an environment variable (complete list follows) to set the URL. The registry in this example does not require authentication.

export CDAF_PUSH_REGISTRY_URL=hub.private.registry
./dockerPush.sh ${SOLUTION}_master_target:${BUILDNUMBER} ${SOLUTION} ${BUILDNUMBER}

Available environment variables

Variable Description
CDAF_PUSH_REGISTRY_URL Image registry URL, example myregistry.local (do not set for dockerhub)
CDAF_PUSH_REGISTRY_TAG Image tag(s), can being single value latest or list latest ${BUILDNUMBER} (default is latest)
CDAF_PUSH_REGISTRY_USER Registry user, example registryuser (if not set, default is ‘.’)
CDAF_PUSH_REGISTRY_TOKEN Registry token, example xyzx9234sxsrwcqw34