- Azure DevOps
When developing an application you always need to manage different environments and versions for your application. To deliver a new version of your project, one way to do it will be:
This kind of process is too long and error prone, while the only thing you want is to have the same version between your Git tag and your application package delivered. So why not just read the Git tag?
To solve this problem I developed a new set of Azure DevOps tasks called
Mobile Versioning, easy to use in your pipeline and free. This group of tasks provide a way to extract the version from a Git repository tag and apply this version to your mobile application as you want.
This group contains multiple tasks, the most important one is the
ExtractVersionFromTag. To use it in your
azure-pipelines.yml you just have to call it like this:
- task: ExtractVersionFromTag@1 inputs: projectFolderPath: '$(Build.SourcesDirectory)' # Optional. Default is: $(Build.SourcesDirectory)
This will extract the version of the last tag you pushed to your Git repository, from the branch you selected to build your pipeline. Then the task will assign each part of your tag to a global variable.
For example if you have a tag with a value of
1.2.3 this will automatically assign the global variables
$(MAJOR) to 1,
$(MINOR) to 2 and
$(PATCH) to 3. In addition this task will compute the number of commits from the first commit on your branch to this this tag and assign this value to
$(NUMBER_OF_COMMITS). These 4 variables will then be usable in your
By convention the Git tags are defined like this:
v(Major).(Minor).(Patch). But the
ExtractVersionFromTag task also manages the tags defined without the
This task can be used whatever the technology you use for your Azure DevOps pipelines.
Mobile Versioning tasks currently provide 3 tasks to help mobile developers to automatically update their iOS and Android applications versions whatever the mobile technology you used.
These tasks can be used with or without using the
ExtractVersionFromTag task before.
To automatically update the version of your application, you just need to add these tasks after using the
For iOS to update the
- task: UpdateiOSVersionInfoPlist@1 inputs: infoPlistPath: 'your_project/Info.plist' bundleShortVersionString: '$(MAJOR).$(MINOR).$(PATCH)' # Optional. Default is: $(MAJOR).$(MINOR).$(PATCH) bundleVersion: '$(NUMBER_OF_COMMITS)' # Optional. Default is: $(NUMBER_OF_COMMITS)
If you need to update the
- task: UpdateAndroidVersionManifest@1 inputs: androidManifestPath: 'your_project/AndroidManifest.xml' versionName: '$(MAJOR).$(MINOR).$(PATCH)' # Optional. Default is: $(MAJOR).$(MINOR).$(PATCH) versionCode: '$(NUMBER_OF_COMMITS)' # Optional. Default is: $(NUMBER_OF_COMMITS)
If you need to update the
build.gradle inside the
- task: UpdateAndroidVersionGradle@1 inputs: buildGradlePath: 'your_project/app/build.gradle' versionName: '$(MAJOR).$(MINOR).$(PATCH)' # Optional. Default is: $(MAJOR).$(MINOR).$(PATCH) versionCode: '$(NUMBER_OF_COMMITS)' # Optional. Default is: $(NUMBER_OF_COMMITS)
Notice that for these 3 tasks you can override the default value of the properties for example instead of:
you can concatenate it with whatever variable you previously define:
or simply use it like this:
This project is a first starting point to help developers managing their applications versions. Feel free to contribute to this project if you want.
You will find examples of use in the Github project repository.