I'm having userName and passWord field in my Azure DevOps Variable group,
and I would like to pass the userName and passWord to my python script as a command line argument, I'm able to get the userName without any issue but passWord is not coming when I pass it from my pipeline script. I tried printing using echo - its printing empty - not evening printing masked value like this '*****'
Please find my pipeline code below:
trigger:
- none
variables:
- group: myVariableGrp
pool:
name: myAgents
stages:
- stage: Testing
jobs:
- job: Test
displayName: Test script
steps:
- task: Bash@3
displayName: Test variable
inputs:
targetType: inline
script: |
echo "hello variables"
echo $USER_NAME
echo $MY_PASSWORD
- task: CmdLine@2
displayName: Test Python script
inputs:
script: python test.py $USER_NAME $MY_PASSWORD
test.py
import sys
# total arguments
#n = len(sys.argv)
#print("Total arguments passed:", n)
print("UserName:", sys.argv[1])
print("Password:", sys.argv[2])
I'm getting the below error:
Traceback (most recent call last):
File "test.py", line 12, in <module>
print("Password:", sys.argv[2])
IndexError: list index out of range
##[error]Bash exited with code '1'.
Finishing: Test Python script