Grgit fails on teamcity


(Martin) #1

Hi, I have build a versioning script. It has to switch between two branches (gradleVersioning and feature/gradle). The script has to checkout and push these branches. Running it locally works as designed. On teamcity push fails silently and after second checkout grgit does not recognize changes in my propertiy files.
I do use https auth via systemproperties.
my task dependencies:

build.finalizedBy artifactoryPublish
artifactoryPublish.finalizedBy updateDev
updateDev.dependsOn gitCommitToMaster

task gitCommitToMaster should commit and push changes made prior in the build:

task gitCommitToMaster {
group ‘gradleVersioning’
description ‘checks out dev branch and commits the new version (-SNAPSHOT cut off) in .s2i and gradle.properties’
doLast {
grgit = Grgit.open(dir: ‘.’)

grgit.checkout(branch: 'origin/gradleVersioning', createBranch: false)
grgit.add(patterns: ['gradle.properties', '.s2i/bin'])

grgit.commit {
    message = 'automated Gradle Commit'
    all = false
}
grgit.tag.add(name: "V${version}")
grgit.push(remote: 'origin', refsOrSpecs: ['gradleVersioning'], tags: true)
grgit.fetch()
grgit.pull(remote: 'origin', branch: 'gradleVersioning')
//grgit.reset(mode: 'hard', commit: 'origin/gradleVersioning')
grgit.close()
println "gitCommitToMaster successful"

}
}

task updateDev does change the version and then also commits/pushes

task updateDev {
group ‘gradleVersioning’
description ‘increments the version number and writes it to local project’
doLast {
grgit = Grgit.open(dir: ‘.’)
//grgit.fetch(refSpecs: [‘refs/remotes/feature/gradle’])

grgit.checkout(branch: 'origin/feature/gradle', createBranch: false)
//grgit.pull(remote: 'origin', branch: 'feature/gradle')
versionMap['Minor'] = (versionMap['Minor'] as Integer) + 1
versionMap['Patch'] = 0
/*This task will be extended when we switch from basic to semantic versioning*/
def newVersion = "${versionMap['Major']}.${versionMap['Minor']}.${versionMap['Patch']}-SNAPSHOT"
println "incremented version for Dev branch: ${newVersion}"
try {
    writeToProperties.call(newVersion, "gradle.properties")
    writeToProperties.call(newVersion, ".s2i/bin/assemble")
    println 'writing new version to working directory -> successful'
}
catch (IOException ex) {
    println "gradle.properties in root is not found or locked"
}
println "start git add, commit and push to DevBranch"
grgit.add(patterns: ['gradle.properties', '.s2i/bin'])
grgit.commit {
    message = 'automated Gradle commit for version update'
    all = false
}
grgit.push(remote: 'origin', refsOrSpecs: ['feature/gradle'])
grgit.reset(mode: 'hard', commit: "origin/feature/gradle")
grgit.close()
println "-> was successful"

}
}

errorlog:

gitCommitToMaster (1s)
[13:44:14]gitCommitToMaster successful
[13:44:14]:updateDev
[13:44:14]incremented version for Dev branch: 3.1338.0-SNAPSHOT
[13:44:14]write to gradle.properties successful
[13:44:14]write to gradle.properties successful
[13:44:14]writing new version to working directory -> successful
[13:44:14]start git add, commit and push to DevBranch
[13:44:14]
[13:44:14]
[13:44:14]BUILD FAILED
[13:44:14]
[13:44:14]Total time: 1 mins 16.886 secs
[13:44:14]##teamcity[buildProblem identity=’-398317399’ description=‘Execution failed for task |’:updateDev|’. org.eclipse.jgit.api.errors.TransportException: Nothing to push.’ type=‘gradleBuildProblem’]
[13:44:15]Process exited with code 1
[13:44:15]Gradle failure report
[13:44:15]FAILURE: Build failed with an exception.
[13:44:15]
[13:44:15]* Where:
[13:44:15]Build file ‘/home/tcagent/buildAgent/work/9630fb096086b628/build.gradle’ line: 293
[13:44:15]
[13:44:15]* What went wrong:
[13:44:15]Execution failed for task ‘:updateDev’.
[13:44:15]> Nothing to push.
[13:44:15]
[13:44:15]* Try:
[13:44:15]Run with --info or --debug option to get more log output.
[13:44:15]
[13:44:15]* Exception is:
[13:44:15]org.gradle.api.tasks.TaskExecutionException: Execution failed for task ‘:updateDev’.
[13:44:15] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
[13:44:15] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
[13:44:15] at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
[13:44:15] at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
[13:44:15] at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
[13:44:15] at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
[13:44:15] at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
[13:44:15] at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
[13:44:15] at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
[13:44:15] at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
[13:44:15] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
[13:44:15] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
[13:44:15] at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
[13:44:15] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
[13:44:15] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
[13:44:15] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
[13:44:15] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
[13:44:15] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
[13:44:15] at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
[13:44:15] at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
[13:44:15] at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
[13:44:15] at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
[13:44:15] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
[13:44:15] at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
[13:44:15] at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
[13:44:15] at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
[13:44:15] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
[13:44:15] at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
[13:44:15] at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
[13:44:15] at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
[13:44:15] at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
[13:44:15] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
[13:44:15] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
[13:44:15] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
[13:44:15] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
[13:44:15] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
[13:44:15] at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
[13:44:15] at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
[13:44:15] at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
[13:44:15] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
[13:44:15] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
[13:44:15] at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
[13:44:15] at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
[13:44:15] at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
[13:44:15] at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
[13:44:15] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:51)
[13:44:15] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)
[13:44:15] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:244)
[13:44:15] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)
[13:44:15] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)
[13:44:15] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
[13:44:15] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
[13:44:15] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
[13:44:15] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)
[13:44:15] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)
[13:44:15] at org.gradle.launcher.Main.doAction(Main.java:33)
[13:44:15] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
[13:44:15] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)
[13:44:15] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)
[13:44:15] at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
[13:44:15] at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:31)
[13:44:15] at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:108)
[13:44:15] at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
[13:44:15]Caused by: org.eclipse.jgit.api.errors.TransportException: Nothing to push.
[13:44:15] at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:180)
[13:44:15] at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:85)
[13:44:15] at java_util_concurrent_Callable$call$0.call(Unknown Source)
[13:44:15] at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:85)
[13:44:15] at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy)
[13:44:15] at java_util_concurrent_Callable$call.call(Unknown Source)
[13:44:15] at java_util_concurrent_Callable$call.call(Unknown Source)
[13:44:15] at org.ajoberstar.grgit.internal.OpSyntax.mapOperation(OpSyntax.groovy:33)
[13:44:15] at org.ajoberstar.grgit.internal.OpSyntax$mapOperation.callStatic(Unknown Source)
[13:44:15] at org.ajoberstar.grgit.Grgit.push(Grgit.groovy)
[13:44:15] at org.ajoberstar.grgit.Grgit$push$4.call(Unknown Source)
[13:44:15] at build_4vt9fauifmm8g0g715qp7omw0$_run_closure17$_closure35.doCall(/home/tcagent/buildAgent/work/9630fb096086b628/build.gradle:293)
[13:44:15] at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:596)
[13:44:15] at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:577)
[13:44:15] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
[13:44:15] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
[13:44:15] … 62 more
[13:44:15]Caused by: org.eclipse.jgit.errors.TransportException: Nothing to push.
[13:44:15] at org.eclipse.jgit.transport.Transport.push(Transport.java:1332)
[13:44:15] at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:169)
[13:44:15] … 77 more