1 | initial version |
To create a file in Azure Pipeline and save it in SharePoint using the command line, follow these steps:
First, ensure that you have the necessary permissions and access to the SharePoint site where you want to save the file.
In your Azure Pipeline, add a Command Line task.
In the Command Line task, use the echo
command to create the content of the file. For example, to create a new file named example.txt
with the content Hello World!
, you can use the following command:
echo "Hello World!" > example.txt
curl
command to make a POST request to the SharePoint site. The command should look like the following:curl --ntlm -u username:password -T example.txt "https://yourdomain.sharepoint.com/sites/yoursite/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents/')/Files/add(url='example.txt',overwrite=true)"
Replace username
and password
with your SharePoint credentials. Replace yourdomain.sharepoint.com
with the URL of your SharePoint site, and yoursite
with the name of the SharePoint site. In the example above, the file is saved in the Shared Documents
folder. You can change the folder by modifying the GetFolderByServerRelativeUrl
parameter.