Reputation: 2146
I currently have a yaml Azure Pipeline that generates Excel files as artifacts and I would like to upload them to a SharePoint folder. I would like to achieve this using Power Automate.
I understand how to run my Power Automate flow when the pipeline finishes. My issue is about understanding how to extract the Excel files from Azure Pipeline artifacts using Power Automate to then push them to SharePoint.
Upvotes: 2
Views: 418
Reputation: 5842
As far as I have tested, there is no action in Power Automate to retrieve pipeline artifacts. Since Azure DevOps itself is an automation tool, we can upload the Excel files onto SharePoint folder directly during a pipeline agent job.
We can use the 3rd-party extension Upload files to SharePoint Online - Visual Studio Marketplace to upload .xls
files from the working directory on the pipeline agent onto the SharePoint target folder; see for more details on how the task authenticates access to SharePoint against App registration in Azure AD.
Here is my sample pipeline for your refence, together with the API permission settings of my app registration that is used by the pipeline task to authenticate access to SharePoint.
variables:
- group: ARM
- name: CurrentTime
value : $[ format('{0:yyyy}-{0:MM}-{0:dd} {0:HH}:{0:mm}:{0:ss}', pipeline.startTime) ]
pool:
vmImage: windows-latest
jobs:
- job: Prep
steps:
- checkout: none
- powershell: |
Write-Host "Current Time is $(currentTime)"
Write-Host "Tenant Id is $(TenantId)"
Write-Host "Client Id is $(ClientId)"
displayName: List variables
- powershell: |
$data = [PSCustomObject]@{
TimeStamp = "$(CurrentTime)"
ProjectName = "$(System.TeamProject)"
PipelineName = "$(Build.DefinitionName)"
DefinitionId = "$(System.DefinitionId)"
BuildId = "$(Build.BuildId)"
}
$data | Export-Csv -Path "BuildData.csv" -NoTypeInformation
Write-Host "Files in $(System.DefaultWorkingDirectory)"
tree $(System.DefaultWorkingDirectory) /F /A
displayName: Generate csv file
- powershell: |
Install-Module ImportExcel -Scope CurrentUser -Force
Import-Csv -Path "BuildData.csv" | Export-Excel -Path "$(Build.DefinitionName)-$(Build.BuildId)-1.xls" -WorksheetName "BuildInfo"
Import-Csv -Path "BuildData.csv" | Export-Excel -Path "$(Build.DefinitionName)-$(Build.BuildId)-2.xls" -WorksheetName "BuildInfo"
Write-Host "Files in $(System.DefaultWorkingDirectory)"
tree $(System.DefaultWorkingDirectory) /F /A
displayName: Generate xls file
- task: az-pipelines-2-sharepoint@0
displayName: Upload the xls files from System.DefaultWorkingDirectory to SharePoint site
inputs:
tenantId: '$(TenantId)'
clientId: '$(ClientId)'
clientSecret: '$(ClientSecret)'
driveId: 'https://$(SharePointOnline).sharepoint.com/sites/AzureDevOpsTeamSite/Shared%20Documents/'
targetFolder: 'AzureDevOpsExcel'
sourceFolder: '$(System.DefaultWorkingDirectory)'
contents: '**/*.xls'
conflictBehaviour: 'replace'
cleanTargetFolder: false
flattenFolders: false
failOnEmptySource: false
Upvotes: 2