I am trying to download certificate file in azure pipelines. I have declared it as a download secureFile task in one of yaml files of my pipeline.
- task: DownloadSecureFile@1
name: certificateFileName
displayName: 'Download file Operation'
inputs:
secureFile: mycert.crt
I also have another task which is the PowerShell script say Install.ps1. This script tries to import the certificate using Import-Certificate function.
Import-Certificate -FilePath "$(certificateFileName.secureFilePath)" -CertStoreLocation "Cert:\LocalMachine\Root"
I am getting an error as ObjectNotFound
when trying to use $(certificateFileName.secureFilePath)
within the function.
I also tried using $(Agent.TempDirectory)
to get the path of downloaded File as suggested by the Microsoft docs. This also results in ObjectNotFound
error.
According to this stackoverflow link, it says that the path gets stored by default in $secureFilePath
environment variable. I also tried to use this variable directly into my Import-Certificate function, but it seems the variable is empty.
What to do in this case? How do I check if download task is correctly downloading and storing the filepath? Just a sidenote, this pipeline also has a variables.yaml declared to define variables to be used across the entire pipeline tasks.