Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 732
Lukas Avatar asked Dec 18 '18 20:12

Lukas


People also ask

What is $( build SourcesDirectory?

Build.SourcesDirectory. The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s. By default, new build pipelines update only the changed files. Important note: If you check out only one Git repository, this path will be the exact path to the code.

How do I find my build number in Azure DevOps?

Build numbers in Azure DevOps For example, Microsoft's Build Number format documentation gives an example: $(TeamProject)_$(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:. r) will result in a version number like Fabrikam_CIBuild_main_20090805. 2 .

How do I find build number in release pipeline?

If you linked a build as release artifact, then you can use $(Build. BuildNumber) to get build number. If you have the issue, please provide the details of your release pipeline (Linked artifact, Docker push task setting, detail log).


1 Answers

You can create a text file using powershell task.

use following commands inside powershel task

New-Item pathtoFile\test.txt
Set-Content pathToFile\test.txt '$(Build.BuildNumber)'
like image 57
Channa Avatar answered Sep 17 '22 20:09

Channa