0

I have to create builds depending on environment and tag/push to nexus. Currently, I have tagTemplate = 'release-${version}' in my release settings. The first part of the tagTemplate (release) is what we're using in our pipeline to fire off the builds, which require slightly different args for each.

I need to be able to pass in an argument that will replace 'release' with some other build type.

Ideally, I'd like to be able to just pass in what goes in the 'release' part of the template, so the setting would look like:

tagTemplate = '${tagPrefix}-${version}'

Then I'd be able to run the command:

gradle release -PtagPrefix='build1'

I've tried passing it in like this:

gradle release -PtagTemplate='build1-${version}'
gradle release -Prelease.tagTemplate='build1-${version}'
gradle release -Pproject.release.tagTemplate='build1-${version}'

None of these work.

1 Answers1

0

gradle release -PtagPrefix would be available via roject.findProperty('tagPrefix'). I'm not sure if you can use template strings for the property args as it depends when they are evaluated.

I would recommend either

release {
    def tagPrefix = project.findProperty('tagPrefix') != null ? project.findProperty('tagPrefix') : 'default'
    tagTemplate = '${tagPrefix}-${version}'
}
Hillkorn
  • 633
  • 4
  • 12