Giter Site home page Giter Site logo

allegro / axion-release-plugin Goto Github PK

View Code? Open in Web Editor NEW
544.0 16.0 147.0 2.4 MB

Gradle release & version management plugin.

Home Page: https://axion-release-plugin.readthedocs.io/

License: Apache License 2.0

Groovy 70.47% Dockerfile 0.32% Java 28.24% Kotlin 0.98%
gradle-release gradle gradle-plugin versioning semantic-versioning release-automation release hacktoberfest

axion-release-plugin's Introduction

axion-release-plugin

gradle release and version management plugin

Build Status Coverage Status readthedocs Maven Central Gradle Plugin Portal

Releasing versions in Gradle is very different from releasing in Maven. Maven came with maven-release-plugin which did all the dirty work. Gradle has no such tool and probably doesn't need it anyway. Evolution of software craft came to the point, when we start thinking about SCM as ultimate source of truth about project version. Version should not be hardcoded in pom.xml or build.gradle.

axion-release-plugin embraces this philosophy. Instead of reading project version from buildfile, it is derived from nearest tag in SCM (or set to default if nothing was tagged). If current commit is tagged commit, project has a release version. If there were any commits after last tag, project is in SNAPSHOT version. This very simple and intuitive philosophy, alongside with Semantic Versioning rules, makes it a lot easier to manage project versions along SCM tag versions.

JDK11+ & Gradle 7+ required.

Basic usage

plugins {
    id 'pl.allegro.tech.build.axion-release' version '1.15.1'
}

project.version = scmVersion.version
$ git tag
<empty list>

$ ./gradlew currentVersion
0.1.0-SNAPSHOT

$ ./gradlew release

$ git tag
v0.1.0

$ ./gradlew cV
0.1.0

$ git add -A && git commit -m "Updates something" && ./gradlew release

$ git tag
v0.1.0
v0.1.1

$ ./gradlew cV
0.1.1

Documentation

Documentation is available at axion-release read the docs.

License

axion-release-plugin is published under Apache License 2.0.

axion-release-plugin's People

Contributors

adamdubiel avatar bgalek avatar big-andy-coates avatar cliffred avatar cloudshiftchris avatar david0 avatar dependabot[bot] avatar duschata avatar dzikoysk avatar erichsend avatar friederbluemle avatar janderssonse avatar john-tipper avatar jplucinski avatar kindrat avatar kkocel avatar lwasyl avatar martinda avatar mc1arke avatar mkoester avatar mpern avatar pwielgolaski avatar rafalh avatar rzabini avatar shashken avatar smialykot avatar szpak avatar trombka avatar vbuell avatar worms308 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

axion-release-plugin's Issues

Release jgit error Transport Exception.. USERAUTH fail

So I have my project cloned using ssh://git@host:xxxx/blah/blah.git I can perform all get actions without being prompted for a password or authentication.

When I do the gradle release - it does all of the work

Creating tag: release 1.0.0
Pushing all to remote: origin
:release FAILED

TransportException: ssh://git@xxx/blah/blah.get USERAUTH fail

caused by PushCommand.java 160
caused by JschConfigSessionFactory.getSession 142
caused by jsch.JSchException : USERAUTH fail
UserAuthPublicKey.start(UserAuthPublicKey.java: 120)

I did a git push --tags and they all when to the server without issue...

Working with git flow and develop branch

I am using the git flow model to manage my repository. Unfortunately this leads to a problem with the currentVersion task. All my work is going to the development branch. At some time I make a release, let's say 0.1.0. My master now contains a Tag 0.1.0. Now I start working for 0.2.0 in development.
First Problem:
Current Version in development branch still is 0.1.0-SNAPSHOT (which I can solve by setting a Tag with release-0.2.0-alpha)
Second Problem:
I make a hotfix for version 0.1.0 which leads to a Tag release-0.1.1 in Master, but with the merge of the hotfix branch back to development branch, currentVersion now is 0.1.1-SNAPSHOT, because now the Tag of my first release also is known in the development branch.
Is there a solution with a special versionCreator?
bildschirmfoto 2015-02-19 um 10 57 38

axion should always release if force version

It's impossible to release forced version when:

  • we are currently on released version but we want to release yet another version (say, we have many releasing branches and I want to release from the same position both 1.0.0 and 0.99.15)
  • in case if something went wrong last time and axion already had created tag but later didn't managed to push changes to remote; and we want to re-release it again after we have fixed the issue

For cases like this it make sense to treat forceVersion option more strictly way - it should try to re-release the version if possible, even if we are already on released version.

Problem integrating plugin with gradle-git...

I think this plugin is great, but I can't get it to work when I combine it with another plugin...
classpath 'org.ajoberstar:gradle-git:0.12.0'

the currentVersion and verifyRelease methods work as expected...
~/workspace/publish-example$ gradle currentVersion
:currentVersion
Project version: 0.1.16-SNAPSHOT
BUILD SUCCESSFUL
Total time: 1.36 secs

but when I say

gradle r
:verifyRelease
Looking for uncommited changes..
Checking if branch is ahead of remote..
:release FAILED
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':release'.

    Input string is NULL or empty

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    BUILD FAILED

Caused by: java.lang.IllegalArgumentException: Input string is NULL or empty
at com.github.zafarkhaja.semver.VersionParser.(VersionParser.java:162)
at com.github.zafarkhaja.semver.VersionParser.parsePreRelease(VersionParser.java:222)
at com.github.zafarkhaja.semver.Version.setPreReleaseVersion(Version.java:431)
at com.github.zafarkhaja.semver.Version$setPreReleaseVersion$2.call(Unknown Source)
at pl.allegro.tech.build.axion.release.ReleaseTask.release(ReleaseTask.groovy:40)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)

If I take out the gradle-git plugin - the release works as expected. Any ideas?

BTW - I think this is a great alternative for releasing, especially coming from a maven background.

Simple script -- just comment out the line - and you see it breaks...

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath group: 'pl.allegro.tech.build', name: 'axion-release-plugin', version: '0.9.4'
// classpath 'org.ajoberstar:gradle-git:0.12.0'
}
}
apply plugin: 'axion-release'
apply plugin: 'maven-publish'

scmVersion {
tag {
prefix = 'release'
}
}

project.group = 'com.yourdomain'
project.version = scmVersion.version

def artifactRepositoryURL
if (project.version.toString().contains("-SNAPSHOT")) {
artifactRepositoryURL = 'http://localhost:8081/content/repositories/snapshots/'
}
else {
artifactRepositoryURL = 'http://localhost:8081/content/repositories/releases/'
}

repositories {
mavenCentral ()
}

dependencies {
}

publishing {
publications {
myPublication(MavenPublication) {
artifact ('README.txt') {
classifier = 'README'
extension = 'txt'
}
}
}
repositories {
maven {
url artifactRepositoryURL
credentials {
username = 'admin'
password = 'admin123'
}

    }
}

}

Type-o in the doc..

versionCreator 'versionWithBrach' // use one of predefined version creators

This error message really confused me for a second! I cut and pasted the line from the readme into my build script and it failed - saying invalid option! I did not realize the n was missing from the word branch.

Thanks for supporting this, and great work!

Release not working in Jenkins - Push fails with message "Nothing to push"

Executing gradle release via Jenkins is not working for me. I'm using gradle 2.3 and the jenkins git plugin 2.3.5.

I can reproduce that on a development machine when executing a checkout of a certain revision as it is done by jenkins git checkout -f eced05a5302fa1bc452f57d3accc504965157344.
I'm using the default git plugin.
The Exception is the following.

:release
Executing task ':release' (up-to-date check took 0.001 secs) due to:
  Task has not declared any outputs.
Working on released version 0.3.2, nothing to release.
Pushing all to remote: origin
The following authentication options are allowed (though they may not be available): [HARDCODED, SSHAGENT, PAGEANT, INTERACTIVE]
:release FAILED
:release (Thread[main,5,main]) completed. Took 0.478 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':release'.
> Problem pushing to remote.

* Try:
Run with --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':release'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:306)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: org.ajoberstar.grgit.exception.GrgitException: Problem pushing to remote.
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:117)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
    at org.ajoberstar.grgit.Grgit.methodMissing(Grgit.groovy:175)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.callPush(GitRepository.groovy:80)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.push(GitRepository.groovy:76)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.push(GitRepository.groovy:72)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmRepository$push$2.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.infrastructure.GradleAwareScmService.push(GradleAwareScmService.groovy:30)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmService$push$0.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.Releaser.pushRelease(Releaser.groovy:54)
    at pl.allegro.tech.build.axion.release.domain.Releaser$pushRelease$1.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.ReleaseTask.release(ReleaseTask.groovy:16)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 44 more
Caused by: org.eclipse.jgit.api.errors.TransportException: Nothing to push.
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:160)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:79)
    at java_util_concurrent_Callable$call$0.call(Unknown Source)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:114)
    ... 66 more
Caused by: org.eclipse.jgit.errors.TransportException: Nothing to push.
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1197)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
    ... 69 more

Any ideas to get around that, or is there a fix required?

release could not resolve dependencies....

Sorry for the rash of problems, I did my testing on an normal network, but have moved to a more secure, air-gapped network. Unfortunately, our repository server requires authentication and I did not realize that the plug-in was going to "fetch" more dependencies from the repository at run time.

The plugin is failing because it cannot grab jgit,jgit-ui, slf4j, jsch,... I'm getting a 401 error (unauthorized)

Sorry, I cleaned my cache and they came in like proper "transitive" dependencies

Release and publish with one command

When building a release I typically want everything to be done with one command, including the uploading to a repository and preparing a new snapshot version.
The docs state that you have to execute the publish in a separate command because otherwise the version would not be correct, but there is an easy workaround for that: fork a new gradle build for the upload.

This is how I modified my gradle build file:

task updateReadme << {
    // I just found out that this is already supported :)
}

task commitReadme << {
    // I just found out that this is already supported :)
}

task forkedUpload(type: GradleBuild) {
    buildFile = project.buildFile
    // update the readme before uploading, because the distributions contain the readme
    tasks = ['updateReadme', 'uploadArchives', 'commitReadme']
}

// when releasing, I always want to do a clean and run all tests
build.mustRunAfter(clean)
release.dependsOn(clean, build)

release << {
    tasks.forkedUpload.execute()
}

I think that it makes sense to provide this functionality out of the box in the release plugin:

scmVersion {
    preReleaseTasks= [clean, build] //or predefined hooks 'clean' and 'build' that are added by default? 
    uploadArchives= true //default
}

UnexpectedCharacterException when using with Jenkins

A job created with default configuration for Git fails with

com.github.zafarkhaja.semver.UnexpectedCharacterException (no error message)

After some digging it seems that Axion takes also non matching tags to pass it to semver when on a tag. Jenkins in turn creates jenkins-job-name-X when cloning project from a repo.

Tested with Axion 1.2.0 and 1.2.3.

Steps to reproduce.

git clone https://github.com/Codearte/gradle-nexus-staging-plugin.git #or anything else with Axion
./gradlew cV               #works fine
git tag jenkins-foo-5
./gradlew cV               #exception

Longer stacktrace:

* What went wrong:
A problem occurred evaluating root project 'gradle-nexus-staging-plugin'.
> com.github.zafarkhaja.semver.UnexpectedCharacterException (no error message)
* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'gradle-nexus-staging-plugin'.
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
(...)
Caused by: Unexpected character 'LETTER(j)' at position '0', expecting '[DIGIT]'
    at com.github.zafarkhaja.semver.VersionParser.consumeNextCharacter(VersionParser.java:516)
    at com.github.zafarkhaja.semver.VersionParser.digits(VersionParser.java:448)
    at com.github.zafarkhaja.semver.VersionParser.numericIdentifier(VersionParser.java:408)
    at com.github.zafarkhaja.semver.VersionParser.parseVersionCore(VersionParser.java:285)
    at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:255)
    at com.github.zafarkhaja.semver.VersionParser.parseValidSemVer(VersionParser.java:195)
    at com.github.zafarkhaja.semver.Version.valueOf(Version.java:265)
    at com.github.zafarkhaja.semver.Version$valueOf.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at pl.allegro.tech.build.axion.release.domain.VersionFactory.create(VersionFactory.groovy:17)
    at pl.allegro.tech.build.axion.release.domain.VersionFactory$create.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
    at pl.allegro.tech.build.axion.release.domain.VersionResolver.resolveVersion(VersionResolver.groovy:21)
    at pl.allegro.tech.build.axion.release.domain.VersionResolver$resolveVersion.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at pl.allegro.tech.build.axion.release.domain.VersionService.currentDecoratedVersion(VersionService.groovy:34)
    at pl.allegro.tech.build.axion.release.domain.VersionService$currentDecoratedVersion.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
    at pl.allegro.tech.build.axion.release.domain.VersionConfig.getVersion(VersionConfig.groovy:91)
    at pl.allegro.tech.build.axion.release.domain.VersionConfig_Decorated.getVersion(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:60)
    at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:153)
    at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObject.java:107)
    at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:78)
    at pl.allegro.tech.build.axion.release.domain.VersionConfig_Decorated.getProperty(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
    at build_cxczvsypzye5vt7n1iyqd57kg.run(/tmp/gradle-nexus-staging-plugin/build.gradle:28)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
    ... 45 more

NPE on pushing changes to GitHub with GH_TOKEN

An alternative way to push changes to GitHub (useful especially from CI server) is the usage of personal access token. Unfortunately it fails with NPE from jgit.

Caused by: java.lang.NullPointerException
    at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:476)
    at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:396)
    at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1173)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:79)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.push(GitRepository.groovy:80)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmRepository$push$5.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.Releaser.release(Releaser.groovy:42)
    at pl.allegro.tech.build.axion.release.domain.Releaser$release.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.ReleaseTask.release(ReleaseTask.groovy:40)
(...)

I debugged it briefly and GH returns 401 on the first connection try and in the second attempt it does not have a credential provider which causes NPE. In jgit master they modified code and more verbose TransportException would be probably throw.

I din't dig into that, but the connection URI is:

https://[email protected]/foo/bar.git/info/refs?service=git-receive-pack

which returns 401 (Unathorized). After change it (in debuger) to just https://[email protected]/foo/bar.git/ it returns 200, but later fails on NotSupportedException: remote does not support smart HTTP push.

Steps to reproduce:

  1. Checkout any project with Axion configured from GH.
  2. Change remote url to url = https://${YOUR_GH_TOKEN}@github.com/you/your-project.git
  3. Call ./gradlew release.

Btw, manual push with mentioned configuration works fine. Tested with Axion 0.9.9.

Trying to execute command in an uninitialized repository???

Stupid question.... I have my project structured as follows.

root
root/build-tools (directory)
root/build-tools/build.gradle

From the root directory - I try to do a release like this...

gradle -b build-tools/build.gradle release

This fails with the exception in the title...

Is there any way to specify where the .git directory is located?

I did all of my testing in a "fake" repository and everything worked perfectly, but when I moved to the real repo, it had a slightly different structure.

Thanks. Phil

Version tag different from scmVersion.version

For some reason the version that goes into tag and the version that is returned by scmVersion.version differ.

I have a version defined like this (YY.M.X where YY is year, M is month, X is incremental restarting from 1 every month). The problem I'm having is that while scmVersion.version creates these correctly as months switch, the version that goes into the tag only increment the last digit.

So if my last tag is PREFIX-15.2.12 then scmVersion.version returns PREFIX-15.3.1 (as month is now 3) while the tag is created as PREFIX-15.2.13.

Am I doing something wrong or is this a bug in how the versionCreator is used?

My version creator:

    versionCreator { version, position ->
        Pattern p = Pattern.compile("([0-9]+)[.]([0-9]+)[.]([0-9]+)")
        Matcher m = p.matcher(version);
        if (m.find()) {
            int year = Integer.parseInt(m.group(1))
            int month = Integer.parseInt(m.group(2))
            int minor = Integer.parseInt(m.group(3))

            Calendar cal = Calendar.getInstance();
            cal.setTime(new Date());
            if ((cal.get(Calendar.YEAR) % 100) != year || cal.get(Calendar.MONTH) != (month - 1)) {
                minor = 1
            }

            return String.format("%02d.%s.%s",
                    cal.get(Calendar.YEAR) % 100,
                    cal.get(Calendar.MONTH) + 1,
                    minor)
        }

        return version
    }

Sanitize versions to match Semver specification

Custom versions should be sanitized to match Semver criteria, i.e. contain only [0-9A-Za-z-]. This is useful when using branch name in version name, branches tend to have some strange chars like "/".

Ability to enable dryRun mode in runtime

I like dryRun mode, but recently I've met one its limitation. I use my dryRun property to control a few deployment related tasks (including release from Axion). I wanted to control dryRun mode in Axion by setting release.dryRun property in a task which Axion depends on, but it didn't work fully. After some debugging I discovered that DryRepository is created in ReleaseTask constructor and it is to late to modify it.

There could a plugin configuration property dryRun (set in scmVersion closure) which could be set/override by the user (and internally used by the plugin). By default it should take project.hasProperty("release.dryRun") value.

Abitlity to create a release branch and to use createReleaseCommit on it

Some workflows involve the creation of a release branch. Would this be an appropriate feature for this plugin? A branch would be created, then a release commit would be made to that branch. IT would work along with the createReleaseCommit feature, in the sense that the commit would be made to the release branch. The release branch would be named in a similar manner as the tag is named. What do you think?

Add possibility to release without remote

Now it is impossible to release without any remote attached:

 org.ajoberstar.grgit.exception.GrgitException: refs/heads/master is not set to track another branch

There should be a check that would skip remote resolution, so releasing without remote is possible. Warning message should be printed instead.

There is an incompatible JNA native library installed on this system.

Testing this plugin for the first time, so bare with me if I'm making some stupid newbie mistake.

I get this error when running the Release task for the first time. I have no preexisting tags in the repo, locally or remotely. The remote repo is in Gerrit. This is a multi-project build.

My dev machine is a Windows host, and I run gradlew from a "git bash" console (minGW).

I read the below like there is an incompatibility between the Java environment that runs my Gradle, and some library which is called by axion-release-plugin. How can I get around this?

If I manually deleted the tag and tried again, I got an even more cryptic error : 'Bad method call from inside of a branch'.

user@host /c/workspace/myproject (master)
$ gradlew --version

------------------------------------------------------------
Gradle 2.2-20141002220015+0000
------------------------------------------------------------

Build time:   2014-10-02 22:00:15 UTC
Build number: none
Revision:     cfcfc3a224acceee6a4ae1f823af15ba56ceab13

Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.7.0_71 (Oracle Corporation 24.71-b01)
OS:           Windows 7 6.1 amd64

user@host /c/workspace/myproject (master)
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean

user@host /c/workspace/myproject (master)
$ git tag

user@host /c/workspace/myproject (master)
$ gradlew release -Prelease.forceVersion=0.0.1
:verifyRelease
Looking for uncommited changes..
Checking if branch is ahead of remote..
:release
Creating tag: release-0.0.1
Pushing all to remote: origin
:release FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':release'.
>

  There is an incompatible JNA native library installed on this system.
  To resolve this issue you may do one of the following:
   - remove or uninstall the offending library
   - set the system property jna.nosys=true
   - set jna.boot.library.path to include the path to the version of the
     jnidispatch library included with the JNA jar file you are using


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 27.295 secs

user@host /c/workspace/myproject (master)
$ git tag -d release-0.0.1
Deleted tag 'release-0.0.1' (was 7797695)

user@host /c/workspace/myproject (master)
$ gradlew release -Prelease.forceVersion=0.0.1 --stacktrace
:verifyRelease
Looking for uncommited changes..
Checking if branch is ahead of remote..
:release
Creating tag: release-0.0.1
Pushing all to remote: origin
:release FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':release'.
> Bad <init> method call from inside of a branch
Exception Details:
  Location:
    org/ajoberstar/grgit/exception/GrgitException.<init>(Ljava/lang/String;)V @8
7: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: b800 164d 04bd 0029 5903 2b53 5910 ff12
    0000010: 04b8 002f 2a5f ab00 0000 00af 0000 0005
    0000020: 8794 83a0 0000 0032 aad3 b1ff 0000 0047
    0000030: c783 a456 0000 005a f0c1 c756 0000 0087
    0000040: 0000 9b75 0000 00a6 5f5a 5903 3212 31b8
    0000050: 0035 c000 315f 57b7 0037 a700 755f 5a59
    0000060: 0332 b800 3dc0 003f 5f57 b700 42a7 0062
    0000070: 5f5a 5903 32b8 003d c000 3f5f 5904 3212
    0000080: 31b8 0035 c000 315f 5905 32b8 0048 5f59
    0000090: 0632 b800 485f 57b7 0018 a700 355f 5a59
    00000a0: 0332 b800 3dc0 003f 5f59 0432 1231 b800
    00000b0: 35c0 0031 5f57 b700 4ba7 0016 5f5a 57b7
    00000c0: 004e a700 0dbb 0050 5912 52b7 0053 bf57
    00000d0: 2ab6 001c 4e2d 2a5f b500 1e2d 57b1
  Stackmap Table:
    full_frame(@72,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Unin
itializedThis})
    full_frame(@93,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Unin
itializedThis})
    full_frame(@112,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@157,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@188,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@197,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@207,{Object[#2],Object[#63],Object[#85]},{Object[#87]})


* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':release
'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExec
uter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.exec
ute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execut
e(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecu
ter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter
.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execut
e(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter
.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailur
e(AbstractTask.java:305)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.executeTask(AbstractTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.processTask(AbstractTaskPlanExecutor.java:63)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorW
orker.run(AbstractTaskPlanExecutor.java:51)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(Defaul
tTaskPlanExecutor.java:23)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(Defau
ltTaskGraphExecuter.java:88)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTask
ExecutionAction.java:29)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:62)
        at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExec
uter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecu
ter.java:68)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildEx
ecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:62)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecute
r.java:55)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(Default
GradleLauncher.java:149)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradle
Launcher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLaun
cher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildCon
troller.run(InProcessBuildActionExecuter.java:80)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:33)
        at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.jav
a:24)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:36)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProce
ssBuildActionExecuter.java:26)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBu
ild.java:46)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(
WatchForDisconnection.java:35)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute
(ResetDeprecationLogger.java:24)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execut
e(StartStopIfBuildAndStop.java:33)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnRes
ult.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(Forw
ardClientInput.java:71)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(Forw
ardClientInput.java:69)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(For
wardClientInput.java:69)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClien
t.java:60)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBu
ild(EstablishBuildEnvironment.java:70)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.
run(StartBuildOrRespondWithBusy.java:45)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(D
aemonStateCoordinator.java:243)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.do
Build(StartBuildOrRespondWithBusy.java:49)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(Build
CommandOnly.java:34)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.HandleCancel.execute(HandleCan
cel.java:37)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.
java:30)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(Da
emonHygieneAction.java:39)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.e
xecute(CatchAndForwardDaemonFailure.java:32)
        at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed
(DaemonCommandExecution.java:125)
        at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.e
xecuteCommand(DefaultDaemonCommandExecuter.java:52)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$Co
nnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:154)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$Co
nnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128
)
        at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$Co
nnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecut
orImpl$1.run(DefaultExecutorFactory.java:64)
Caused by: java.lang.VerifyError: Bad <init> method call from inside of a branch

Exception Details:
  Location:
    org/ajoberstar/grgit/exception/GrgitException.<init>(Ljava/lang/String;)V @8
7: invokespecial
  Reason:
    Error exists in the bytecode
  Bytecode:
    0000000: b800 164d 04bd 0029 5903 2b53 5910 ff12
    0000010: 04b8 002f 2a5f ab00 0000 00af 0000 0005
    0000020: 8794 83a0 0000 0032 aad3 b1ff 0000 0047
    0000030: c783 a456 0000 005a f0c1 c756 0000 0087
    0000040: 0000 9b75 0000 00a6 5f5a 5903 3212 31b8
    0000050: 0035 c000 315f 57b7 0037 a700 755f 5a59
    0000060: 0332 b800 3dc0 003f 5f57 b700 42a7 0062
    0000070: 5f5a 5903 32b8 003d c000 3f5f 5904 3212
    0000080: 31b8 0035 c000 315f 5905 32b8 0048 5f59
    0000090: 0632 b800 485f 57b7 0018 a700 355f 5a59
    00000a0: 0332 b800 3dc0 003f 5f59 0432 1231 b800
    00000b0: 35c0 0031 5f57 b700 4ba7 0016 5f5a 57b7
    00000c0: 004e a700 0dbb 0050 5912 52b7 0053 bf57
    00000d0: 2ab6 001c 4e2d 2a5f b500 1e2d 57b1
  Stackmap Table:
    full_frame(@72,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Unin
itializedThis})
    full_frame(@93,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Unin
itializedThis})
    full_frame(@112,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@157,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@188,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@197,{UninitializedThis,Object[#63],Object[#85]},{Object[#87],Uni
nitializedThis})
    full_frame(@207,{Object[#2],Object[#63],Object[#85]},{Object[#87]})

        at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:107)
        at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy)
        at java_util_concurrent_Callable$call$0.call(Unknown Source)
        at java_util_concurrent_Callable$call$0.call(Unknown Source)
        at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
        at org.ajoberstar.grgit.Grgit.methodMissing(Grgit.groovy:193)
        at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.
callPush(GitRepository.groovy:87)
        at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.
push(GitRepository.groovy:83)
        at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.
push(GitRepository.groovy:78)
        at pl.allegro.tech.build.axion.release.domain.scm.ScmRepository$push$5.c
all(Unknown Source)
        at pl.allegro.tech.build.axion.release.domain.Releaser.release(Releaser.
groovy:42)
        at pl.allegro.tech.build.axion.release.domain.Releaser$release.call(Unkn
own Source)
        at pl.allegro.tech.build.axion.release.ReleaseTask.release(ReleaseTask.g
roovy:33)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskF
actory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
ctTask.java:579)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(Abstra
ctTask.java:562)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.ex
ecuteActions(ExecuteActionsTaskExecuter.java:61)
        ... 69 more


BUILD FAILED

Total time: 9.751 secs

user@host /c/workspace/myproject (master)
$

verifyRelease always indicates uncommited files

When I execute .gradlew verifyRelease it always indicates there are uncommitted files. However when I execute "git status" or sourcetree on git, everything is up to date.

I have used gradlew --debug to troubleshoot the issue but it does not provide any meaningful information. An enhancement would be for the task to list the uncommitted files and/or to list out any repository details

As this plugin depends on eclipse jgit library, I assume my environment does not have it configured correctly.

CreateVersionInfo task to fix version in build pipeline

When I use axion release plugin within my jenkins build pipeline, only the first job will be able to fetch the version from git repository. For all downstream jobs I prefer to clone the workspace and so I cannot get the version from the plugin.
So it should be possible to call a task in the first job to generate a VersionInfo file, which can be used in other jobs.

Any other ideas?

Optional empty commit on release

It is great that axion doesn't depend on a version kept in a file, but it can be harder to notice a release just browsing commits (as tags are treated separately). There is a releases/tags tab in a GitHub interface, but sometimes it would be desirable to have a commit.

For those cases there could be a switch (disabled by default) which would make an empty commit with a message about release first and then tag it (there could be required an additional switch to allow JGit to accept empty commit).

Check if tag prefixes for multi-module project are not prefixes of each other

If you accidentally configure two subprojects in a multi-module project to use tag prefixes which are prefixes of each other, e.g.:

scmVersion {
    tag {
        prefix = 'something'
    }
} 

and

scmVersion {
    tag {
        prefix = 'something-client'
    }
} 

then releasing the module with longer tag prefix (effectively: creating a git tag such as something-client-1.2.3) will cause the project to become unusable. Any Gradle command including gradle clean ends with:

FAILURE: Build failed with an exception.
* Where:
Build file '/home/mkosmul/src/flex/build.gradle' line: 130
* What went wrong:
A problem occurred evaluating root project 'something'.
> com.github.zafarkhaja.semver.UnexpectedCharacterException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED

This is because Gradle tries to parse the tag something-client-1.2.3 but using the prefix something, which results in it trying to parse client-1.2.3 as a version number, which fails. However, the error message is very confusing.

The best thing that can be done here is probably to valdiate all tag prefixes in order to ensure not one of them is a prefix of any other, thus preventing the confusing error message from appearing.

Make it possible to release different version for each module

As a user i would like it to be possible to release different version (based on different tags) for each module in my project. Now it only sees the first interpreted scmVersion clause.

Reason: Context object should not try to be a singleton.

Please release to maven central

Hey, this looks great, but we have constraints at work restricting our ability to build our own version of your tool. Do you think you might have some time soon to release the latest version to maven central?

clear push uris before attaching remote using release.attachRemote

Bamboo CI in new 5.6.x version always attaches fake remote when fetching contents from git repository:

* remote origin
    Fetch URL: file:///nothing
    Push  URL: file:///nothing

When using release.attachRemote option of axion-release, another Push URL is added, but it will be never used resulting in failed build:

org.eclipse.jgit.api.errors.TransportException: file:///nothing: not found.

Solution would be to clean all push URLs before attaching new one.

verifyRelease fails even if there are no locacl changes

$ ./gradlew vR
Picked up JAVA_TOOL_OPTIONS: -Xmx1248m -XX:MaxPermSize=800m -Xms512m -Dfile.encoding=UTF-8
:verifyRelease
Looking for uncommitted changes.. FAILED

Staged changes:

Unstaged changes:
    added: .idea/checkstyle-idea.xml
    added: .idea/.name
    added: .idea/gradle.xml
    added: .idea/encodings.xml
    added: .idea/uiDesigner.xml
    added: .idea/compiler.xml
    added: .idea/workspace.xml
    added: .idea/findbugs-idea.xml
    added: .idea/modules.xml
    added: .idea/misc.xml
    added: .idea/vcs.xml
    added: .idea/qaplug_profiles.xml

:verifyRelease FAILED
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean
$ git status --ignored
On branch master
Your branch is up-to-date with 'origin/master'.

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)

        .gradle/
        .idea/.name
        .idea/checkstyle-idea.xml
        .idea/compiler.xml
        .idea/copyright/
        .idea/encodings.xml
        .idea/findbugs-idea.xml
        .idea/gradle.xml
        .idea/libraries/
        .idea/misc.xml
        .idea/modules.xml
        .idea/qaplug_profiles.xml
        .idea/scopes/
        .idea/uiDesigner.xml
        .idea/vcs.xml
        .idea/workspace.xml

.gitignore

/**/bin
.idea/**/*
!.idea/codeStyleSettings.xml
target/
out/
build/
/*/pl/
/*/src/generated/
.gradle
*.iml
*.ipr
*.iws

Callback closure just before the release commit

Moving toward CD I see a necessity to do additional operations during the release cycle. Some of them (like publish artifacts, close GH milestone) can (or even should) be done after the release done by Axion, but other great fit the phase just before the release commit is performed (like update README, or regenerate changelog file) to be committed by Axion.

It would be useful to have an ability to define a callback closure to do whatever needed (including calling tasks from external plugins) just before the release commit is performed. To update README just previous and current versions are needed, but it would be probably better to use some structure passed as a closure parameter to extend it in the future (e.g. to update changelog it would be useful to have all the commit from the last release).

WDYT?

How to perform major version updates, using multiple branches...

The "initalVersion" concept works great for boot strapping the version process, but I have not figured out how to best manager "major" releases -- which is very easy with the maven pom - just edit the version number!

Here is my issue.

  1. We created initial version 1.0.0 on a release/1.0 branch (gradle release)
  2. We created the next version, 1.0.1 on a release/1.0 branch (gradle release)
  3. We are continuing development on a development branch
  4. We want to produce version 2.0.0-SNAPSHOT artifacts from the development branch.
  • Unfortunately, the development branch reports 1.0.2-SNAPSHOT --- but we want to push the 2.0-* snapshots to nexus
  • This is a new "major" release that everyone is calling 2.x -- not 1.x

I can't find any way to solve this -- I created a 2.0.0-dev tag -- to get the "major" number correct, but now the plugin reports 2.0.1-SNAPSHOT -- which is also confusing...

I don't think is is an uncommon process.. this is how we did things with maven.. Let me know if I'm missing something or how I can generate the desired SNAPSHOT versions.

Thanks again!

Unable to release from CI Server (JENKNIS)

I'm using the standard git plugin from jenkins and when I run - I provided the additional parameter to attach to the remote..
./gradlew release -Prelease.attachRemote="ssh://[email protected]/repo.git"

However, it still fails -- with HEAD is not set to track another branch. I also configured the GIT plugin to check out to a specific branch - but get the same error.

To debug a little, I logged onto the CI server and tried to do a push of the project. The remote (push) repo was updated appropriately... but the push failed with

To push the current branch and set the remote as upstream, use
git push --set-upstream origin master

And then the git push worked from the shell -- BUT the Jenkins job still fails with the same error.

Any thoughts? Thanks

NullPointerException on push (jgit update needed)

I have a multi-module project and cant't get release to work...

$ ./gradlew release --stacktrace
:verifyRelease
Looking for uncommitted changes.. 
Checking if branch is ahead of remote.. 
:release
Creating tag: project-0.1.0
Pushing all to remote: origin
:release FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':release'.
> java.lang.NullPointerException (no error message)

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':release'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
    at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:33)
    at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
    at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.lang.NullPointerException
    at com.jcraft.jsch.Session.checkHost(Session.java:802)
    at com.jcraft.jsch.Session.connect(Session.java:342)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:136)
    at org.eclipse.jgit.transport.TransportGitSsh$SshPushConnection.<init>(TransportGitSsh.java:320)
    at org.eclipse.jgit.transport.TransportGitSsh.openPush(TransportGitSsh.java:166)
    at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:154)
    at org.eclipse.jgit.transport.Transport.push(Transport.java:1200)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:156)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:79)
    at java_util_concurrent_Callable$call$0.call(Unknown Source)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:114)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at java_util_concurrent_Callable$call.call(Unknown Source)
    at org.ajoberstar.grgit.util.OpSyntaxUtil.tryOp(OpSyntaxUtil.groovy:45)
    at org.ajoberstar.grgit.Grgit.methodMissing(Grgit.groovy:175)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.callPush(GitRepository.groovy:86)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.push(GitRepository.groovy:82)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.push(GitRepository.groovy:78)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmRepository$push$5.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.infrastructure.GradleAwareScmService.push(GradleAwareScmService.groovy:30)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmService$push$1.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.Releaser.pushRelease(Releaser.groovy:54)
    at pl.allegro.tech.build.axion.release.domain.Releaser$pushRelease$1.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.ReleaseTask.release(ReleaseTask.groovy:16)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 47 more


BUILD FAILED

Total time: 9.612 secs

build.gradle:

buildscript {
    repositories {
        maven { url "http://our/artifactory/repo" }
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.1'
    }
}

plugins {
    id 'pl.allegro.tech.build.axion-release' version '1.2.4'
}

scmVersion {
    tag {
        prefix = 'project'
    }
}

allprojects {
    repositories {
        maven { url "http://our/artifactory/repo" }
        mavenLocal()
        jcenter()
    }
    project.version = scmVersion.version
}

$ ./gradlew --version

------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------

Build time:   2014-11-24 09:45:35 UTC
Build number: none
Revision:     6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a

Groovy:       2.3.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_40 (Oracle Corporation 25.40-b25)
OS:           Linux 3.19.0-15-generic amd64
$ git remote -v
origin  ssh://git@stash/project/repo.git (fetch)
origin  ssh://git@stash/project/repo.git (push)

Problem with repositoryDir

Maybe it is problem with my configuration, but repositoryDir doesn't work for me to point a Git repository root in a parent dir. See my configuration in a sample project reproducing that issue.

I see No repository found at ... warning on currentVersion and

* What went wrong:
Execution failed for task ':verifyRelease'.
> Trying to execute command in an uninitialized repository.

on release.

Axion 0.9.9.

Migrate documentation to RTD

README.md is getting too big, i need to migrate documentation (making it better on the way) to readthedocs.org. GitHub wiki is not as good, since it's separate wiki repository to keep in sync. RTD will be kept in same repository, and so axion-release can update version etc.

Changes from a feature branche are always pushed to origin

On release changes from tracked upstream for given branch are fetch, but later always pushes to origin (even if remote is set to an another repository). It's a rare case, but for consistency push should also take into account set remote.

Predefined version creators

As user i want some widely-used version creators to be predefined in axion-release-plugins and accessible via simple setting, for example:

versionCreator: 'versionWithBranch'

Using commit hook causes release task to fail on Windows.

build.gradle contains:

scmVersion {
    hooks {
        pre 'fileUpdate', [...]
        pre 'commit'
    }
}

Running gradlew release results in error:

:verifyRelease
Looking for uncommitted changes..
Checking if branch is ahead of remote..
:release
Creating release commit
:release FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':release'.
> Illegal/unsupported escape sequence near index 3
  C:\Users\donb\src\myproject/
     ^

Stack trace:

Caused by: java.util.regex.PatternSyntaxException: Illegal/unsupported escape sequence near index 3
C:\Users\dboths001c\src\workflow\comcast-base/
   ^
    at java_lang_String$replaceFirst$3.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository$_commit_closure1.doCall(GitRepository.groovy:132)
    at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.commit(GitRepository.groovy:132)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmRepository$commit$4.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.infrastructure.GradleAwareScmService.commit(GradleAwareScmService.groovy:35)
    at pl.allegro.tech.build.axion.release.domain.scm.ScmService$commit.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.hooks.HookContext.commit(HookContext.groovy:32)
    at pl.allegro.tech.build.axion.release.domain.hooks.HookContext$commit$0.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.hooks.CommitHookAction.act(CommitHookAction.groovy:18)
    at pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHookAction$act.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHookAction$act.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHooksRunner$_runPreReleaseHooks_closure1.doCall(ReleaseHooksRunner.groovy:25)
    at pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHooksRunner.runPreReleaseHooks(ReleaseHooksRunner.groovy:25)
    at pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHooksRunner$runPreReleaseHooks.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.domain.Releaser.release(Releaser.groovy:41)
    at pl.allegro.tech.build.axion.release.domain.Releaser$release.call(Unknown Source)
    at pl.allegro.tech.build.axion.release.ReleaseTask.release(ReleaseTask.groovy:24)

Line 132 of GitRepository.groovy:

repository.add(patterns: patterns.collect { it.replaceFirst(repositoryDir.canonicalPath + '/', '') })

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.