azureazure-devopsazure-pipelinesazure-pipelines-release-pipeline

Azure DevOps Pipelines: Create a text file with the current build number


I have a build and pipeline setup to build a solution and then upload the finished .exe file via ftp upload to my website. Everything works fine and I have it setup to make a new folder named $Build.BuildNumber (20181218.4 for example) with the .exe file in it so I can keep an archive of my finished builds.

Now I want to write the BuildNumber to a text file sitting somewhere in the root directory with a static path/url so my programms can read the file and get the newest build number and download the newest .exe.

How can I automate the process of creating such a text file with Azure DevOps Pipelines?


Solution

  • You can create a text file using powershell task.

    use following command inside powershel task

    Set-Content pathToFile\test.txt '$(Build.BuildNumber)'