az-pipelines-2-sharepoint is an Azure DevOps extensions to upload file or build artefacts to a SharePoint Online library via Microsoft Graph.
This extension can not be used with on-premise SharePoint installations.
Azure Pipelines: Visit the Marketplace page and click install. Choose your Azure DevOps organization.
Azure DevOps Server: Visit the Marketplace page and click install. Then choose Download and install it via the Extension page on your local Azure DevOps Server.
Register a new application in your Azure AD tenant: (For more info, refer to the Microsoft Docs)
Microsoft Graph
-> Application permissions
-> Files
-> Files.ReadWrite.All
(The extension will have full access to all SharePoint drives!)Microsoft Graph
-> Application permissions
-> Sites
-> Sites.Selected
.Upload files to SharePoint Online
task to your build pipeline.https://contoso.sharepoint.com/sites/some-project/Shared%20Documents
/build-files/$(Build.BuildID)
contents
parameter. Leave this parameter empty to use the current working directory of the pipeline.**
will upload all files recursively.build-files/**/*.txt
will copy only txt-files recursively unter build-files
These parameters can be found at the application registration page in Azure AD. Microsoft Docs
conflictBehaviour: File conflict behaviour
(optional, default: fail)
Specifies how the task should handle a file where the target file already exists. There are 3 different options:
Fail
, Replace
, Rename
For more info see this docs article.
cleanTargetFolder: Clean Target folder
(optional, default: false)
If set to true, the task will delete all files from the target folder.
flattenFolders: Flatten Folders
(optional, default: false)
If set to true, all files will be copied to the target folder without retaining the source folder structure.
failOnEmptySource: Fail if no files found to copy
(optional, default: false)
If set to true, the task will fail if no matching files are found under the source folder.
Parameter source
is left blank to use the current working directory. This copies all files from the dist folder in the current working dir.
steps:
- task: halliba.az-pipelines-2-sharepoint.az-pipelines-2-sharepoint.az-pipelines-2-sharepoint@0
displayName: 'Upload files to SharePoint'
inputs:
tenantId: 'CCCCCCCC-2222-4444-6666-333333333333'
clientId: 'AAAAAAAA-1111-3333-5555-FFFFFFFFFFFF'
clientSecret: '1234567890abcdefghijABCDEFGHIJ1234567890'
driveId: 'https://contoso.sharepoint.com/sites/some-project/Shared%20Documents'
targetFolder: '/build-files/$(Build.BuildId)/'
contents: 'dist/**'
steps:
- task: halliba.az-pipelines-2-sharepoint.az-pipelines-2-sharepoint.az-pipelines-2-sharepoint@0
displayName: 'Upload files to SharePoint'
inputs:
...
sourceFolder: '$(Build.ArtifactStagingDirectory)'
contents: '/bin/**/*.dll'
steps:
- task: halliba.az-pipelines-2-sharepoint.az-pipelines-2-sharepoint.az-pipelines-2-sharepoint@0
displayName: 'Upload files to SharePoint'
inputs:
...
sourceFolder: '/var/some-folder/' #or 'D:\some-folder' for Windows
contents: '**/*.log'