Terminus code to check for Environments
Mon Aug 15 2022 19:25:16 GMT+0000 (UTC)
Saved by
@MattMoniz
#yaml
#terminus
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript
trigger:
- none
pool:
vmImage: ubuntu-latest
variables:
- name: branchName
value: $(Build.SourceBranchName)
steps:
- task: NodeTool@0
inputs:
versionSpec: '14.x'
displayName: 'Install Node.js'
- task: Bash@3
inputs:
targetType: 'inline'
script: 'brew install pantheon-systems/external/terminus'
- script: |
terminus auth:login --machine-token=$(TERMINUS_TOKEN)
displayName: 'Terminus Authentication'
- task: Bash@3
inputs:
targetType: 'inline'
script: |
#!/bin/bash
# Exit on error
set -e
MULTIDEV_EXISTS="false"
# Stash list of all Pantheon sites in the org
PANTHEON_SITES="$(terminus multidev:list -n bmc-org --format=list --field=Name)"
# Loop through each site in the list
while read -r PANTHEON_SITES
do
# if the branch is found then let user know that this branch exists and exit the script.
if [ $PANTHEON_SITES == $(branchName) ];
then
MULTIDEV_EXISTS="true"
echo "Existing multidev URL: https://$(branchName)-bmc-org.pantheonsite.io/"
break
fi
done <<< "$PANTHEON_SITES"
if [ $MULTIDEV_EXISTS == "true" ];
then
echo "Multidev was found!"
"$(terminus env:clone-content --verbose bmc-org.live abc)"
else
echo "Error: multidev environment named "$(branchName)" was not found."
exit 1
fi
failOnStderr: true
continueOnError: false
- task: Bash@3
inputs:
targetType: 'inline'
script: |
#!/bin/bash
PANTHEON_PIPELINE_CLONE="$(terminus env:clone-content --verbose healthcity.live pipelines)"
echo $(PANTHEON_PIPELINE_CLONE)
continueOnError: false
displayName: 'Updating Multidev Environments'
content_copyCOPY
Comments