Skip to content

Triggering Deployments#

Trigger a new deployment using Azure Pipelines#

In order to automatically trigger new deployments using Azure Pipelines follow these instructions:

  1. Add your deployment SSH private key to Azure as a secure file as id_rsa_lagoon. For more information about secure files have a look at the Azure Documentation Site.
  2. Add the following configuration to your azure-pipelines.yml:
  vmImage: 'ubuntu-latest'

  # .. other stages
  - stage: Deploy
    condition: and(succeeded(), in(variables['Build.SourceBranch'], 'refs/heads/staging', 'refs/heads/develop'))
      - job: DeployLagoon
        - task: DownloadSecureFile@1
          name: lagoonSshKey
          displayName: 'Download Lagoon SSH key'
            secureFile: id_rsa_lagoon
        - script: |
            curl -L "" -o ./lagoon
            chmod +x ./lagoon
          displayName: 'Download lagoon-cli'
        - script: ./lagoon login -i $(lagoonSshKey.secureFilePath)
          displayName: 'Log into Lagoon'
        - script: ./lagoon deploy branch -e $(Build.SourceBranchName) -p my-awesome-project -b $(Build.SourceBranchName) --force
          displayName: 'Trigger deployment using lagoon-cli'

This will trigger a new deployment whenever changes are made on the develop or staging branch. Adjust these values accordingly so they fit your deployment strategy and configuration.

Push without deploying#

There may be a case where you want to push without a deployment. Make sure your commit message contains "[skip deploy]" or "[deploy skip]" and Lagoon will not trigger a deployment from that commit.