Search code examples
azure-devopspipeline

How to access Secure file in a bash script


Using classic editor, i download a secure file via download securefile task. I am setting the reference name to mySecureFile

download secure file I have a bash script (not inline) where I am trying to use this secure file. This is the line in script sf auth jwt grant --username $env:USERNAME_BAUQA --jwt-key-file $(Agent.TempDirectory)/mySecureFile.key --client-id $env:CLIENTID_BAUQA --instance-url $env:INSTANCE_URL_BAUQA

I am getting an error /home/vsts/work/1/s/auth_sf.sh: line 4: Agent.TempDirectory: command not found

Can you help

for script to access the secure file


Solution

  • According to your secure file task, the file name should be server.key not mySecureFile.key.

    Besides the way $AGENT_TEMPDIRECTORY/server.key in the script suggested by @Sanad Bhowmik.

    You can also specify the working directory to $(Agent.TempDirectory) for the bash task, remember to remove the path for the file in the script.

    #!/bin/bash
    
    sf auth jwt grant --username $env:USERNAME_BAUQA --jwt-key-file server.key --client-id $env:CLIENTID_BAUQA --instance-url $env:INSTANCE_URL_BAUQA
    

    enter image description here