Skip to content

Instantly share code, notes, and snippets.

@willianantunes
Created July 7, 2019 16:14
Show Gist options
  • Save willianantunes/78eb26943c634973d9920ba23c546270 to your computer and use it in GitHub Desktop.
Save willianantunes/78eb26943c634973d9920ba23c546270 to your computer and use it in GitHub Desktop.
Sample logic about how to set variable on Azure DevOps
import os
import sys
branch_name: str = sys.argv[1]
print(f"Received argument: {branch_name}")
env_image_type = "ENV_IMAGE_TYPE"
def set_value(key, value):
print(f"Set key {key} as {value}")
print(f"##vso[task.setvariable variable={key};]{value}")
if "develop" in branch_name:
set_value(env_image_type, "dev")
elif "release" in branch_name:
set_value(env_image_type, "qa")
elif "master" in branch_name:
set_value(env_image_type, "prd")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment