axion-release-plugin icon indicating copy to clipboard operation
axion-release-plugin copied to clipboard

cannot set current branch name for tags automatically

Open maciolek opened this issue 4 years ago • 2 comments

Hi, I would like to use axion-release-plugin to name my version artifacts and tag prefix in azure devOps pipeline. I tried all tips from https://axion-release-plugin.readthedocs.io/en/latest/configuration/ci_servers/#azure-devops-pipelines like:

./gradlew release
-Prelease.disableChecks
-Prelease.pushTagsOnly
-Prelease.overriddenBranchName=$(Build.SourceBranch) but it still doesn't work properly. For artifacts version it works, but for tag name doesn't.

In build.gradle::

apply plugin: 'pl.allegro.tech.build.axion-release' dependencies { classpath "pl.allegro.tech.build:axion-release-plugin:1.10.3" }

//Even I tried this solution but It gets only HEAD name of branch. Look at below task: // I constantly get HEAD instead of current branch name def getCurrentBranch() { def branch = "" def proc = "git rev-parse --abbrev-ref HEAD".execute() proc.in.eachLine { line -> branch = line } proc.err.eachLine { line -> println line } proc.waitFor() branch }

scmVersion { ignoreUncommittedChanges = true versionCreator {version, position -> position.getBranch() + "_" + version }

//Below lines don't work
//tag.prefix = position.getBranch()
//tag.prefix = getCurrentBranch()    
//tag.prefix = 'versionWithBranch'

} project.version = scmVersion.version

I would like to have different tags for every branch (depends on current branch name) instead of release. It should work something like 'versionWithBranch'.

For example: branch name: release2101 -> tag: release2101 branch name: testBranch8 -> tag: testBranch8 Is there any way to that automatically?

versionCreator works fine, thanks!

maciolek avatar Mar 27 '21 19:03 maciolek

Have you tried the different configuration options? See https://axion-release-plugin.readthedocs.io/en/latest/configuration/overview/, check out tag configuration.

mockitoguy avatar Mar 27 '21 21:03 mockitoguy

Yes, I read it. Unfortunately I don't know how to add proper prefix tag per every current branch automatically, every time after create new one. I tried this config, it doesn't work. my current branch -> azureDevOps

1st ex:

tag { // doc: Version / Parsing
    prefix = 'tag-prefix' // prefix to be used, 'v' by default, empty String means no prefix
    branchPrefix = [ // set different prefix per branch
        'az/.*' : 'versionWithBranch'
    ]

I got tag: versionWithBranch-0.1.0 insted of release

2nd ex.

tag { // doc: Version / Parsing
    prefix = 'versionWithBranch' // prefix to be used, 'v' by default, empty String means no prefix
    branchPrefix = [ // set different prefix per branch
        'azz.*' : 'versionWithBranch'
    ]
}

Could not get unknown property 'versionWithBranch' for object of type pl.allegro.tech.build.axion.release.domain.TagNameSerializationConfig.

These ways below don't work too:

-Prelease.scmVersion.tag.prefix='$(Build.SourceBranchName)' -Prelease.tag.prefix='$(Build.SourceBranchName)' -Prelease.scmVersion.tag.prefix=$(Build.SourceBranchName) -Prelease.tag.prefix=$(Build.SourceBranchName)

Could you give me some example or a hint?

maciolek avatar Mar 28 '21 21:03 maciolek