A
A
a000_000a2018-09-21 16:13:51
Jenkins
a000_000a, 2018-09-21 16:13:51

How to increment project version in version.properties file?

The task is such that there is a version.properties in the repository, you need to pull the version from this file (major.minor.patch) and, depending on whether it is a hotfix or just a merge, change the patch or mines. Tell me how to implement this on Groovy in the Jenkins pipeline.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
a000_000a, 2018-09-21
@a000_000a

def str = readProperties  file:'version.properties'
        v = str['version']
                Integer major = version.split("\\.")[0] as Integer
                Integer minor = version.split("\\.")[1] as Integer
                Integer patch = version.split("\\.")[2] as Integer
                patch += 1
                minor += 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question