Thank you David, I think what you’re saying does make sense. After seeing your reply, I considered the option to write the variable into a text file, which I can then have Jenkins read. The code I’m using is below, it outputs the version number fine but I can’t find the exact method to append the basename before the version number, after trying a number of ways. What I want the file’s content to be is just “Archive-APR-1.01”
version = '1.01'
archiveValue = 'Archive-APR'
tasks.create('versionFile') {
outputs.file('versionFile.txt')
inputs.property "archiveValue"
inputs.property ('version', property.version)
doLast {
project.file('versionFile.txt') << property.version
}
}
UPDATE: After looking some more, I saw a simpler approach to achieve the purpose. This code seems to work well for my need, and also achieves the other goal, to overwrite the file rather than append:
version = '1.01
def archiveValue = 'Archive-APR'
task versionTxt() {
doLast {
new File("version.txt").text = "${archiveValue}-${version}"
}
}