trigger:
- master
jobs:
- job: build
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
- task: PythonScript@0
inputs:
scriptSource: 'inline'
script: |
import os
print(os.environ.get('account_name')) # NONE
print(os.environ.get('ACCOUNT_NAME')) # NONE
print(os.environ.get('account_name_var')) # NONE
- script: echo $(ACCOUNT_NAME) # Print *** can be accessed
env:
account_name_var: $(account_name)
Try to put the environment variables under the script that you want to print them. Check the example below:
- script: |
python env.py
displayName: 'env'
env:
account_name_var: $(account_name)
Change your PythonScript task like this:
- task: PythonScript@0
displayName: 'Run a Python script'
inputs:
scriptSource: inline
script: |
import os
print(os.environ.get('ACCOUNT_NAME'))
env:
ACCOUNT_NAME: $(account_name)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.