Update Version Variables And PackageThe UpdateVersionVariablesAndPackage VSTS task updates the variables that are used to name the artifact and is used to perform replacements in the application. This task is used to perform autoversioning of artifacts and application versions. It is recommended to use Git Flow. ImportantGit: Only Tested with Azure DevOps git. Agent Specification: Tested on Windows and Linux. DocumentationTo create an upgrade version, pipeline variables are used: Major, Minor and Patch As a summary, the final version is also stored in the variable: VersionTag and VersionJava Configure the tasks in YAML
Configure the tasks in YAML with Templates:
Pre configure the tasks for classic editorConfigure Allow scripts to access the OAuth token:Security:Find the user running the pipeline: First we must enter the "Name of your project" and then Build Service For example: "Project1 Build Service" Set "Edit build pipeline" in "Allow" This is so that the user running the pipeline can update the value of the variables. This must be repeated for each pipeline. Or simply add the user "Name of your project Build Service" to the project Contributors group. So you don't have to give permission on each and every pipe. (Recommended option) Other option is: add the user "Name of your project Build Service" in Organization Group: "Project Collection Build Administrators" With these last options, it is only done once and it is not necessary to then grant permissions in each pipeline. Logic for versioning v 0.*:Deprecated logic. The patch was increased instead of the minor Logic for versioning v 1.*:When a git push is made to the branch, the following procedure is performed: If the git push has a tag in "x.y.z" format The variables are updated: Major, Minor and Patch with the values "x", "y" and "z" If the git push does not have a tag
Example graphs using git flowFeatureBugfixReleaseHotfixVariables that we can use after finishing the task:Version: example output: "1.2.6-20231502-010322" VersionJava: example output: "1.2.6-SNAPSHOT" VersionShort: example output: "1.2.6" NewMajor: example output: "1" NewMinor: example output: "2" NewPatch: example output: "6" Extra variables: To perform overrides in .net frameworks projects: Assembly: example output: "[assembly: AssemblyVersion("1.2.6")]" AssemblyFile: example output: "[assembly: AssemblyFileVersion("1.2.6")]" Output variablesVersionOut: example output: "1.2.6-20231502-010322" VersionJavaOut: example output: "1.2.6-SNAPSHOT" VersionShortOut: example output: "1.2.6" NewMajorOut: example output: "1" NewMinorOut: example output: "2" NewPatchOut: example output: "6" Extra variables: To perform overrides in .net frameworks projects: AssemblyOut: example output: "[assembly: AssemblyVersion("1.2.6")]" AssemblyFileOut: example output: "[assembly: AssemblyFileVersion("1.2.6")]" For use in yaml with templates:Example:
examples to replace variables:For .Net Framework projectsWe use the Replace Tokens task. Before build the solution: replace these values with the value of variable Assembly and AssemblyFile To version your nuget packagesTo replace version in azure DevOps custom task projectThese are some examples among the thousands of uses that the autoversioning of our projects has. Help to continue development.If it helped you. You can help me: https:// paypal.me/solucionespsg |