Reputation: 15039
I have an Azure Pipeline using a YAML that has one task that downloads a zipped secure file:
- task: DownloadSecureFile@1
displayName: Download Testpipelineapp
name: testPipelineapp
inputs:
secureFile: TestPipelineapp.zip
The download happens perfectly, but then I need to extract the contents because inside is an .EXE that I need to execute.
Any clue on how can I do this? I'm new to YAML and Azure Devops.
Upvotes: 1
Views: 6469
Reputation: 114581
There are a couple of options, depending on what's installed in your agent.
The hosted agent comes with a recent enough version of PowerShell to be able to use the Expand-Archive
PowerShell function. And it has 7z
installed, so you could call that too.
- script: |
7z x path-to-downloaded-file.zip path-to-extract-to
path-to-extract-to\myexecutable.exe
# PowerShell
# Run a PowerShell script on Linux, macOS, or Windows
- task: PowerShell@2
inputs:
targetType: inline
#filePath: # Required when targetType == FilePath
#arguments: # Optional
script: |
Expand-archive -file path-to-downloaded-file.zip -Destinationpath path-to-extract-to
& path-to-extract-to\myexecutable.exe
#errorActionPreference: 'stop' # Optional. Options: default, stop, continue, silentlyContinue
#warningPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#informationPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#verbosePreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#debugPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#failOnStderr: false # Optional
#ignoreLASTEXITCODE: false # Optional
pwsh: true
#workingDirectory: # Optional
Then there's the built-in task:
# Extract files
# Extract a variety of archive and compression files such as .7z, .rar, .tar.gz, and .zip
- task: ExtractFiles@1
inputs:
#archiveFilePatterns: '**/*.zip'
destinationFolder:
#cleanDestinationFolder: true
#overwriteExistingFiles: false
#pathToSevenZipTool:
Upvotes: 0
Reputation: 15039
I found how:
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(Agent.TempDirectory)/TestPipelineapp.zip'
cleanDestinationFolder: false
overwriteExistingFiles: true
Then in order to execute the .EXE file I had to add a CMD script task
- task: CmdLine@2
inputs:
script: TestPipelineapp.exe
Upvotes: 2