I have a requirement to upload the build artifacts to SharePoint at the end of the build. using jenkins pipeline.
I didn't find any plugin to achieve this.
My Jenkins instance is running on a Linux machine. Please suggest the best way to achieve this
CodePudding user response:
I am using CLI for Microsoft 365 for this (available for linux as well). Looks somewhat like this:
m365 login --authType password --userName [email protected] --password pass@word1
m365 spo file add --webUrl https://contoso.sharepoint.com/sites/project-x --folder 'Shared Documents' --path 'C:\MS365.jpg'
https://pnp.github.io/cli-microsoft365/cmd/login/
https://pnp.github.io/cli-microsoft365/cmd/spo/file/file-add/
You may need to add special account to your sharepoint for your jenkins, or add an app password to be able to upload file from a daemon process (if your sharepoint requires MFA authentication)