Download a secure file to repo code in Azure Devops Pipelines

302

You can utilize "Download Secure File task" to download from the library on to your agent.

reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/download-secure-file?view=azure-devops

https://docs.microsoft.com/en-us/azure/devops/pipelines/library/secure-files?view=azure-devops

- task: DownloadSecureFile@1
  inputs:
    secureFile: 'secureFile'

- task: CopyFiles@2
  inputs:
    SourceFolder: '$(Agent.TempDirectory)'
    Contents: secureFile
    TargetFolder: '$(Build.ArtifactStagingDirectory)'
Share:
302
Philipp Honsel
Author by

Philipp Honsel

Updated on January 03, 2023

Comments

  • Philipp Honsel
    Philipp Honsel over 1 year

    I am creating a Pipeline to automatically build and release a flutter app. On my machine the flutter build appbundle --release works just fine and also signs the app correctly. I reference a key and a properties file, which I both don't want to upload into the repo, but instead use the Library > Secure Files.

    How can I either download these files onto my Agent to a specific position, or use the downloaded file path in my build.gradle?

  • Philipp Honsel
    Philipp Honsel about 2 years
    I already found this task, but this task downloads the file somewhere onto my agent machine. But I need it in a specific location, so that I can use this location in my build.gradle
  • Ia1
    Ia1 about 2 years
    Yes, the task downloads the file under $(Agent.TempDirectory) on your agent machine and you can use copyFiles task to copy it to your target location which can reference in your properties file.
  • Philipp Honsel
    Philipp Honsel about 2 years
    Thanks! This did in fact work after I changed the $(Build.ArtifactStagingDirectory) to $(Build.SourcesDirectory), since I need it in relation to my code.
  • Ia1
    Ia1 about 2 years
    Oh great. Glad that helped :)