Update a Service
Update the container image used by a DuploCloud Service
Updating a Service
Example Pipeline Script
Example Pipeline
Prerequisites to use the example script without modification
Example Code
parameters:
- name: tag_choice
displayName: Tag (Build ID or short commit hash or branch name) or this-commit or this-branch
type: string
default: this-commit
- name: env_names
displayName: DuploCloud environment/tenant names
type: string
default: dev01,staging01
variables:
- group: duplocloud-secrets
trigger: none
resources:
pipelines:
- pipeline: ecr-publish
source: \api\api-ecr-publish
trigger:
branches:
include:
- develop
steps:
- script: |
export tag_choice=${{ parameters.tag_choice }}
export env_names=${{ parameters.env_names }}
export service_name=$(Build.Repository.Name)
echo $tag_choice
if [ $tag_choice = 'this-commit' ]; then
export tag_choice=${BUILD_SOURCEVERSION:0:8}
fi
if [ $tag_choice = 'this-branch' ]; then
export tag_choice=$(Build.SourceBranchName)
fi
echo $tag_choice
export token=$(DUPLO_TOKEN)
export host=$(DUPLO_HOST)
export ecr_base=$(ECR_BASE)
echo $tenant
pip install duplocloud-client
export IFS=","
for env_name in $env_names; do
echo "Updating service in tenant $env_name"
duploctl --host=$host --token=$token --tenant=$env_name service update_image $service_name $ecr_base/$(Build.Repository.Name):$tag_choice
done
displayName: Update service imageLast updated
Was this helpful?

