Pass variable in Azure devops pipelines
I have an Azure devops pipeline and want to pass some data between different tasks. One way to do is use environment var.
Variables give you a convenient way to get key bits of data into various parts of the pipeline. As the name suggests, the value of a variable may change from run to run or job to job of your pipeline. Almost any place where a pipeline requires a text string or a number, you can use a variable instead of hard-coding a value. The system will replace the variable with its current value during the pipeline’s execution.
To access var, the syntax is $(varname)
, this can be used in Azure devops portal or yaml
file.
Set var across task
To set var in Azure pipeline, need use task.setvariable
in following format:
echo "##vso[task.setvariable variable=myvar]foo bar"
Now in next Azure pipeline task, it use access var myvar
through $(myvar).
Available variables
Azure have predefined variables here.
I curious what variables available and the its value in Azure pipeline so I can better config pipeline use those variables,
I create a Bash task use env
command to log all the environment variables:
Or config this new task through YAML file:
steps:
- bash: |
# Print all the available env vars.
env
displayName: env
For future reference, the following is the env
output:
##[section]Starting: env
=================================================
Task : Bash
Description : Run a Bash script on macOS, Linux, or Windows
Version : 3.163.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
==============================================================================
Generating script.
[command]"C:\Program Files\Git\bin\bash.exe" --noprofile --norc -c pwd
========================== Starting Command Output ===========================
[command]"C:\Program Files\Git\bin\bash.exe" --noprofile --norc /d/a/_temp/a6edbca5-dde4-4b7d-adb3-cf0024c12046.sh
USERDOMAIN=fv-az335
OS=Windows_NT
COMMONPROGRAMFILES=C:\Program Files\Common Files
AGENT_HOMEDIRECTORY=C:\agents\2.164.8
PROCESSOR_LEVEL=6
PSModulePath=C:\Modules\azurerm_2.1.0;C:\Modules\azure_2.1.0;C:\Users\packer\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Microsoft SQL Server\130\Tools\PowerShell\Modules\
RELEASE_ATTEMPTNUMBER=1
CommonProgramW6432=C:\Program Files\Common Files
M2_HOME=C:\ProgramData\chocolatey\lib\maven\apache-maven-3.6.2
REQUESTEDFORID=8df0411e-3c97-6c2e-96c8-c300f2612512
BOOST_ROOT=C:\hostedtoolcache\windows\Boost\1.69.0
RELEASE_DEFINITIONENVIRONMENTID=1
SYSTEM_STAGEDISPLAYNAME=Deploy To Dev
SYSTEM_JOBATTEMPT=1
AGENT_VERSION=2.164.8
GOROOT_1_11_X64=C:\Go1.11.12
ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
RELEASE_REQUESTEDFOREMAIL=Firstname_Lastname@example.com
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
RELEASE_ARTIFACTS__FOO-PRODUCTION_BUILDNUMBER=develop-7513
JAVA_HOME_11_X64=C:\Program Files\Java\zulu-11-azure-jdk_11.33.15-11.0.4-win_x64
SYSTEM_TEAMFOUNDATIONSERVERURI=https://vsrm.dev.azure.com/azx-awesome/
ImageVersion=20200130.1
AGENT_TOOLSDIRECTORY=C:/hostedtoolcache/windows
INPUT_ARGUMENTS=
SYSTEM_DEFINITIONID=1
AGENT_DISABLELOGPLUGIN_TESTFILEPUBLISHERPLUGIN=true
RELEASE_DEPLOYMENTID=17
AGENT_WORKFOLDER=D:\a
RELEASE_RELEASEDESCRIPTION=
AZURE_EXTENSION_DIR=C:\Program Files\Common Files\AzureCliExtensionDirectory
GOROOT_1_9_X64=C:\Go1.9.7
PUBLIC=C:\Users\Public
SYSTEM_DEFINITIONNAME=New release pipeline
AGENT_TEMPDIRECTORY=D:\a\_temp
BOOST_ROOT_1_72_0=C:\hostedtoolcache\windows\Boost\1.72.0
EXEPATH=C:\Program Files\Git\bin
RELEASE_ENVIRONMENTID=14
SYSTEM_PHASENAME=Phase_1
RELEASE_PRIMARYARTIFACTSOURCEALIAS=_FOO-production
SYSTEM_JOBIDENTIFIER=Stage_81682fe045cf4f0289829127534b0b7c_1_1.Phase_1.__default
USERNAME=VssAdministrator
ChocolateyInstall=C:\ProgramData\chocolatey
JAVA_HOME=C:\Program Files\Java\zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64
MonAgentClientLocation=C:\Packages\Plugins\Microsoft.Azure.Geneva.GenevaMonitoring\2.16.0.1\Monitoring\Agent
LOGONSERVER=\\fv-az335
PROCESSOR_ARCHITECTURE=AMD64
SYSTEM_JOBPARALLELISMTAG=Private
M2=\bin
GeckoWebDriver=C:\SeleniumWebDrivers\GeckoDriver
RELEASE_REASON=Manual
RELEASE_ARTIFACTS__FOO-PRODUCTION_TYPE=AzureContainerRepository
RELEASE_RELEASENAME=Release-14
LOCALAPPDATA=C:\Users\VssAdministrator\AppData\Local
RELEASE_DEPLOYMENT_REQUESTEDFOR=Firstname Lastname
M2_REPO=C:\ProgramData\m2
DEPLOY_SLOT=production
COMPUTERNAME=fv-az335
RELEASE_DEPLOYMENT_REQUESTEDFORID=8cf0410e-3c97-6c21-96c8-c30042614512
AGENT_OS=Windows_NT
SYSTEMDRIVE=C:
USERPROFILE=C:\Users\VssAdministrator
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.FOO
SYSTEMROOT=C:\windows
ENDPOINT_URL_SYSTEMVSSCONNECTION=https://vsrm.dev.azure.com/azx-awesome/
USERDOMAIN_ROAMINGPROFILE=fv-az335
RELEASE_REQUESTEDFOR=Firstname Lastname
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 79 Stepping 1, GenuineIntel
SYSTEM_WORKFOLDER=D:\a
GRADLE_HOME=C:\ProgramData\chocolatey\lib\gradle\tools\gradle-6.0.1
AGENT_DISABLELOGPLUGIN_TESTRESULTLOGPLUGIN=true
AGENT_ROOTDIRECTORY=D:\a
RELEASE_RELEASEURI=vstfs:///ReleaseManagement/Release/14
PWD=/d/a/r1/a
MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\
HOME=/c/Users/VssAdministrator
AGENT_ID=42
GOROOT=C:\Go1.12.7
TMP=/tmp
ANDROID_NDK_HOME=C:\Microsoft\AndroidNDK64\android-ndk-r15c
SYSTEM_TOTALJOBSINPHASE=1
RELEASE_ARTIFACTS__FOO-PRODUCTION_BUILDID=develop-7513
SYSTEM_COLLECTIONURI=https://vsrm.dev.azure.com/azx-awesome/
ChromeWebDriver=C:\SeleniumWebDrivers\ChromeDriver
RUNNER_TOOLSDIRECTORY=C:/hostedtoolcache/windows
JAVA_HOME_8_X64=C:\Program Files\Java\zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64
AGENT_OSARCHITECTURE=X64
SYSTEM_CULTURE=en-US
SYSTEM_TEAMPROJECTID=81682fe0-45ce-4f02-8982-9927534b0b7c
RELEASE_ENVIRONMENTNAME=Deploy To Dev
RELEASE_DEPLOYMENT_REQUESTEDFOREMAIL=Firstname_Lastname@example.com
VSTS_AGENT_PERFLOG=c:\vsts\perflog
CONDA=C:\Miniconda
IEWebDriver=C:\SeleniumWebDrivers\IEDriver
BUILD_TYPE=AzureContainerRepository
GOROOT_1_13_X64=C:\Go1.13
BOOST_ROOT_1_69_0=C:\hostedtoolcache\windows\Boost\1.69.0
SYSTEM_JOBPOSITIONINPHASE=1
SYSTEM_JOBID=f1ed5861-42cf-5cea-8ff0-dab22962cff3
PHPROOT=c:\tools\php
AGENT_JOBNAME=Run on agent
SYSTEM_STAGEATTEMPT=1
SYSTEM_PIPELINESTARTTIME=2020-02-11 23:44:55+00:00
RELEASE_DEPLOYPHASEID=17
RELEASE_ENVIRONMENTS_DEPLOY_TO_DEV_STATUS=InProgress
PROCESSOR_REVISION=4f01
RELEASE_ENVIRONMENTURI=vstfs:///ReleaseManagement/Environment/11
SYSTEM_TASKINSTANCENAME=Bash
GOROOT_1_12_X64=C:\Go1.12.7
NUMBER_OF_PROCESSORS=2
SYSTEM_PLANID=2a16d23a-e3d2-4a2e-97c4-b3f7af77a2b7
TASK_DISPLAYNAME=env
ProgramW6432=C:\Program Files
SYSTEM_HOSTTYPE=release
AGENT_SERVEROMDIRECTORY=C:\agents\2.164.8\externals\vstsom
MSDEPLOY_HTTP_USER_AGENT=VSTS_a05a13d9-a33d-47dd-84c4-417f58390198_Release__14_14_1
TF_BUILD=True
RELEASE_DEFINITIONNAME=New release pipeline
AZURE_HTTP_USER_AGENT=VSTS_a05a13d9-a33d-47dd-84c4-417f58390198_Release__14_14_1
GOROOT_1_10_X64=C:\Go1.10.8
SYSTEM_PHASEDISPLAYNAME=Run on agent
COMSPEC=C:\windows\system32\cmd.exe
SYSTEM_TASKDEFINITIONSURI=https://dev.azure.com/azx-awesome/
APPDATA=C:\Users\VssAdministrator\AppData\Roaming
TERM=cygwin
SYSTEM_TASKDISPLAYNAME=env
SYSTEM_STAGENAME=Stage_81682fe045ce4f0289829927534b0b7c_1_1
VSTS_PROCESS_LOOKUP_ID=vsts_0d3956ca-568b-4562-ae99-853674af7845
SYSTEM=release
SYSTEM_PHASEATTEMPT=1
VCPKG_INSTALLATION_ROOT=C:\vcpkg
SYSTEM_JOBNAME=__default
GCM_INTERACTIVE=Never
RELEASE_ARTIFACTS__FOO-PRODUCTION_DEFINTIONID=foo-production
BUILD_DEFINITIONID=foo-production
SYSTEM_PHASEID=e09202ee-4c4c-51e7-8ae6-5ba2c80c73e2
AGENT_RELEASEDIRECTORY=D:\a\r1\a
WINDIR=C:\windows
AGENT_MACHINENAME=fv-az335
RELEASE_REQUESTEDFORID=8cf0410e-3c97-6c21-96c8-c30042614512
agent.jobstatus=Succeeded
COBERTURA_HOME=C:\cobertura-2.1.1
BUILD_DEFINTIONID=foo-production
JAVA_HOME_7_X64=C:\Program Files\Java\zulu-7-azure-jdk_7.31.0.5-7.0.232-win_x64
BUILD_DEFINITIONNAME=foo-production
ANDROID_NDK_PATH=C:\Microsoft\AndroidNDK64\android-ndk-r15c
SYSTEM_ARTIFACTSDIRECTORY=D:\a\r1\a
ProgramData=C:\ProgramData
SHLVL=1
PLINK_PROTOCOL=ssh
NPM_CONFIG_CACHE=C:\npm\cache
PROGRAMFILES=C:\Program Files
AGENT_NAME=Hosted Agent
BUILD_BUILDNUMBER=develop-7513
ALLUSERSPROFILE=C:\ProgramData
TEMP=/tmp
SYSTEM_JOBDISPLAYNAME=Run on agent
MAVEN_OPTS=-Xms256m
SYSTEM_SERVERTYPE=Hosted
SYSTEM_TIMELINEID=3a46d23a-e3d8-4a2e-97c4-b3f7ae77a5c8
RELEASE_TRIGGERINGARTIFACT_ALIAS=
AGENT_RETAINDEFAULTENCODING=false
MSYSTEM=MINGW64
SYSTEM_TASKINSTANCEID=16eb2309-ff06-5080-cfa3-e946532acdc5
SYSTEM_DEFAULTWORKINGDIRECTORY=D:\a\r1\a
AGENT_JOBSTATUS=Succeeded
SBT_HOME=C:\Program Files (x86)\sbt\
ANT_HOME=C:\ProgramData\chocolatey\lib\ant\apache-ant-1.10.5
SYSTEM_TEAMPROJECT=MobileSecurityCore
ProgramFiles(x86)=C:\Program Files (x86)
PATH=/mingw64/bin:/usr/bin:/c/Users/VssAdministrator/bin:/c/hostedtoolcache/windows/Python/3.6.8/x64:/c/hostedtoolcache/windows/Python/3.6.8/x64/Scripts:/c/Program Files/Mercurial:/c/ProgramData/kind:/c/vcpkg:/c/cf-cli:/c/Program Files (x86)/NSIS:/c/Program Files/Mercurial:/c/hostedtoolcache/windows/Boost/1.69.0:/c/Program Files/dotnet:/c/mysql-5.7.21-winx64/bin:/c/Program Files/Java/zulu-8-azure-jdk_8.40.0.25-8.0.222-win_x64/bin:/c/Program Files (x86)/sbt/bin:/c/Rust/.cargo/bin:/c/hostedtoolcache/windows/Ruby/2.5.7/x64/bin:/c/Go1.12.7/bin:/bin:/c/hostedtoolcache/windows/Python/3.6.8/x64/Scripts:/c/hostedtoolcache/windows/Python/3.6.8/x64:/c/npm/prefix:/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/c/Program Files/Microsoft MPI/Bin:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/System32/WindowsPowerShell/v1.0:/c/ProgramData/Chocolatey/bin:/c/Program Files/Docker:/c/Program Files/PowerShell/6:/c/Program Files/dotnet:/c/Program Files/Microsoft SQL Server/130/Tools/Binn:/c/Program Files (x86)/Microsoft SQL Server/110/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/120/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/130/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/140/DTS/Binn:/c/Program Files (x86)/Microsoft SQL Server/150/DTS/Binn:/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/c/Program Files/Microsoft Service Fabric/bin/Fabric/Fabric.Code:/c/Program Files/Microsoft SDKs/Service Fabric/Tools/ServiceFabricLocalClusterManager:/c/Program Files/nodejs:/cmd:/mingw64/bin:/usr/bin:/c/tools/php:/c/Program Files (x86)/sbt/bin:/c/Program Files (x86)/Subversion/bin:/c/SeleniumWebDrivers/ChromeDriver:/c/ProgramData/chocolatey/lib/maven/apache-maven-3.6.2/bin:/c/Program Files/CMake/bin:/c/Strawberry/c/bin:/c/Strawberry/perl/site/bin:/c/Strawberry/perl/bin:/c/Program Files/OpenSSL/bin:/c/Users/VssAdministrator/.dotnet/tools:/c/Program
NPM_CONFIG_PREFIX=C:\npm\prefix
RELEASE_ARTIFACTS__FOO-PRODUCTION_DEFINITIONID=foo-production
WIX=C:\Program Files (x86)\WiX Toolset v3.11\
SELENIUM_JAR_PATH=C:\selenium\selenium-server-standalone.jar
HOMEDRIVE=C:
SYSTEM_COLLECTIONID=a05a13d9-a33d-47dd-84c4-417f58390098
SYSTEM_TEAMFOUNDATIONCOLLECTIONURI=https://dev.azure.com/azx-awesome/
HOMEPATH=\Users\VssAdministrator
RELEASE_DEFINITIONID=1
RELEASE_SKIPARTIFACTSDOWNLOAD=False
GIT_TERMINAL_PROMPT=0
RELEASE_RELEASEID=14
RELEASE_ARTIFACTS__FOO-PRODUCTION_DEFINITIONNAME=foo-production
SYSTEM_STAGEID=95cbcc97-ca20-5423-1f2a-c4d17b4f963c
SYSTEM_ENABLEACCESSTOKEN=False
BUILD_BUILDID=develop-7513
RELEASE_DEPLOYMENT_STARTTIME=2020-02-11 23:44:46Z
RELEASE_RELEASEWEBURL=https://dev.azure.com/azx-awesome/a1682fe0-45ce-4f02-8982-d927534b0b8c/_release?releaseId=14&_a=release-summary
VS140COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\
PYTHON_HOME=C:/hostedtoolcache/windows\Python\3.6.8\x64
_=/usr/bin/env
##[section]Finishing: env
Reference
OmniLock - Block / Hide App on iOS
Block distractive apps from appearing on the Home Screen and App Library, enhance your focus and reduce screen time.
DNS Firewall for iOS and Mac OS
Encrypted your DNS to protect your privacy and firewall to block phishing, malicious domains, block ads in all browsers and apps