Skip to content
This repository has been archived by the owner on Oct 5, 2018. It is now read-only.

Authentication failing when attempting origin push when run inside a jenkins job #145

Closed
bedge opened this issue Nov 12, 2015 · 18 comments
Closed

Comments

@bedge
Copy link

bedge commented Nov 12, 2015

I have a problem where my createReleaseBranch task works when I run it locally, but fails when run from a jenkins CI job.

Here's the output, note that createReleaseTag works fine, but my createReleaseBranch does not:

:workspace:createReleaseTag
Executing task ':createReleaseTag' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Running [git, tag, -a, 3.50.0, -m, [Gradle Release Plugin] - creating tag:  '3.50.0'.] in [/u0/jenkins/jobs/CAS-admin-create-git-release/workspace]
Running [git, tag, -a, 3.50.0, -m, [Gradle Release Plugin] - creating tag:  '3.50.0'.] produced output: []
Running [git, remote] in [/u0/jenkins/jobs/CAS-admin-create-git-release/workspace]
Running [git, remote] produced output: []
Running [git, push, --porcelain, origin, 3.50.0] in [/u0/jenkins/jobs/CAS-admin-create-git-release/workspace]
Running [git, push, --porcelain, origin, 3.50.0] produced output: []
:createReleaseTag (Thread[main,5,main]) completed. Took 0.694 secs.
:createReleaseBranch (Thread[main,5,main]) started.
:workspace:createReleaseBranch
Executing task ':createReleaseBranch' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
release branch name = release/logan
The following authentication options are allowed (though they may not be available): [HARDCODED, SSHAGENT, INTERACTIVE, PAGEANT]
using interactive credentials, if needed
ssh-agent not available
pageant not available
jsch agent proxy not available

I'm hooking into this plugin in my own gradle script using:

updateVersion.dependsOn createReleaseBranch

where createReleaseBranch is:

task createReleaseBranch() {
    group = "Release"
    description = "Create branch (-Drelease.name=<name>) from current develop head"
    doLast {
        def release = System.getProperty("release.name")
        if (null == release) {
            throw new GradleException("-Drelease.name=.. missing.")
        }
        def releaseBranchName = "release/${release}"
        println "release branch name = ${releaseBranchName}"
        def repo = Grgit.open(project.file('.'))
        def branchService = repo.getBranch()
        def developBranch = branchService.getCurrent()
        def branchStatus
        try {
            branchStatus = branchService.getStatus(name: "release/${releaseBranchName}")
            throw new GradleException("Branch ${releaseBranchName} already exists.")
        }
        catch(Exception e) {}   // Expect that branch does not already exist.
        println "About to create branch"
        branchService.add(name: releaseBranchName, startPoint: 'develop', mode: BranchAddOp.Mode.TRACK)
        println "Branch created: ${releaseBranchName}, next push"
        try {
            repo.push(all: true)
            println "Push OK"
        }
        catch(Exception e) {
            // related to  https://github.com/allegro/axion-release-plugin/issues/66 ?
            println "Repo push failed, execute manually. This is usually needed from jenkins."
        }
    }
}

I want to create a branch from develop called release/XXX and push it to the origin.

Is there something I'm missing here?

@bedge bedge changed the title Authentication failing when origin push from jenkins job Authentication failing when attempting origin push when run inside a jenkins job Nov 12, 2015
@ajoberstar
Copy link
Owner

Are you getting a stacktrace or is it just not completing the actions you expect? The output doesn't seem to match up with the way your task is coded (missing some printlns that I would have expected to see). Can you confirm that this is the full output from the code you posted?

@bedge
Copy link
Author

bedge commented Nov 12, 2015

Apologies, that was form a run pre-debug statements.

Here's the latest run from the same code.


:workspace:createReleaseBranch
Executing task ':createReleaseBranch' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
release branch name = release/tom
About to create branch
Branch created: release/tom, next push
The following authentication options are allowed (though they may not be available): [INTERACTIVE, HARDCODED, PAGEANT, SSHAGENT]
ssh-agent not available
pageant not available
jsch agent proxy not available
ssh-agent not available
pageant not available
jsch agent proxy not available
Repo push failed, execute manually. This is usually needed from jenkins.
:createReleaseBranch (Thread[main,5,main]) completed. Took 1.447 secs.
:reanmeDevelopTags (Thread[main,5,main]) started.

@bedge
Copy link
Author

bedge commented Nov 12, 2015

To answer your other question, I'm wondering why the push is not working when run from jenkins. The branch is created in the local repo, but is not propagated to the server.
It works fine when I run it from a local clone not from a jenkins job.

@ajoberstar
Copy link
Owner

This sounds like it's the same as #137, though you're using a custom task instead of org.ajoberstar.release-opinion. It's possible that it's a different issue, since you are using "push all".

Since you're suppressing the exception, I can't tell exactly what the issue. Would you mind modifying your task to print/throw the exception and post the resulting stacktrace?

@bedge
Copy link
Author

bedge commented Nov 24, 2015

Apologies for the delay. Had to wait until next release cycle.

Here's the output, running
gradle -DRELEASE_NAME=melodica -Drelease.type=minor -Drelease.name=melodica -DDEBUG=1 --info --stacktrace release

Is it as simple as it looks and it's just an ssh key mismatch between the client and server?
If that were the case, would the preTagCommit not have failed as well?

gitbranch.gradle:74 is:

            repo.push(all: true)
:runBuildTasks (Thread[main,5,main]) completed. Took 0.848 secs.
:preTagCommit (Thread[main,5,main]) started.
:workspace:preTagCommit
Executing task ':preTagCommit' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Running [git, commit, -a, -m, [Gradle Release Plugin] - pre tag commit:  '3.51.0-SNAPSHOT'.] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, commit, -a, -m, [Gradle Release Plugin] - pre tag commit:  '3.51.0-SNAPSHOT'.] produced output: []
Running [git, remote] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, remote] produced output: []
Running [git, push, --porcelain, origin, develop] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, push, --porcelain, origin, develop] produced output: []
Running [git, push, --porcelain, origin, develop] produced an error: [remote: === hooks/update.secondary.d/catch-conflicts.sh ===�[K
remote: ==== hooks/update.secondary.d/check-forbidden-names.sh ====�[K]
:preTagCommit (Thread[main,5,main]) completed. Took 0.915 secs.
:createReleaseTag (Thread[main,5,main]) started.
:workspace:createReleaseTag
Executing task ':createReleaseTag' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
Running [git, tag, -a, 3.51.0-SNAPSHOT, -m, [Gradle Release Plugin] - creating tag:  '3.51.0-SNAPSHOT'.] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, tag, -a, 3.51.0-SNAPSHOT, -m, [Gradle Release Plugin] - creating tag:  '3.51.0-SNAPSHOT'.] produced output: []
Running [git, remote] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, remote] produced output: []
Running [git, push, --porcelain, origin, 3.51.0-SNAPSHOT] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, push, --porcelain, origin, 3.51.0-SNAPSHOT] produced output: []
Running [git, push, --porcelain, origin, 3.51.0-SNAPSHOT] produced an error: [remote: === hooks/update.secondary.d/catch-conflicts.sh ===�[K
remote: ==== hooks/update.secondary.d/check-forbidden-names.sh ====�[K]
:createReleaseTag (Thread[main,5,main]) completed. Took 0.803 secs.
:createReleaseBranch (Thread[main,5,main]) started.
:workspace:createReleaseBranch
Executing task ':createReleaseBranch' (up-to-date check took 0.0 secs) due to:
  Task has not declared any outputs.
release branch name = release/melodica
About to create branch
Branch created: release/melodica, next push
The following authentication options are allowed (though they may not be available): [PAGEANT, INTERACTIVE, HARDCODED, SSHAGENT]
ssh-agent not available
pageant not available
jsch agent proxy not available
ssh-agent not available
pageant not available
jsch agent proxy not available
:workspace:createReleaseBranch FAILED
:createReleaseBranch (Thread[main,5,main]) completed. Took 1.372 secs.
Stopped 0 compiler daemon(s).
:release FAILED
Release process failed, reverting back any changes made by Release Plugin.
Running [git, checkout, gradle.properties] in [/u0/jenkins/jobs/Store-admin-create-git-release/workspace]
Running [git, checkout, gradle.properties] produced output: []
:release (Thread[main,5,main]) completed. Took 6.212 secs.

FAILURE: Build failed with an exception.

* Where:
Script '/u0/jenkins/jobs/Store-admin-create-git-release/workspace/ci-versioning/gradle/gitbranch.gradle' line: 74

* What went wrong:
Execution failed for task ':createReleaseBranch'.
> 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 ':createReleaseBranch'.
    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:52)
    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.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:62)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:158)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:155)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:36)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:103)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:97)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:97)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.api.tasks.GradleBuild.build(GradleBuild.java:117)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208)
    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)
    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:52)
    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.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:62)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:158)
    at org.gradle.internal.Factories$1.create(Factories.java:22)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:155)
    at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:36)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:103)
    at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:97)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:97)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:102)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:47)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:32)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
    at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
    at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
    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:188)
    at gitbranch_2us8agp9zuuvy0q3yov05bnzh$_run_closure4_closure10.doCall(/u0/jenkins/jobs/Store-admin-create-git-release/workspace/ci-versioning/gradle/gitbranch.gradle:74)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:554)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:535)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 99 more
Caused by: org.eclipse.jgit.api.errors.TransportException: git@git:server/store: UnknownHostKey: git. RSA key fingerprint is f7:ac:7a:bb:62:3f:1e:cc:66:6d:82:63:5b:6b:7c:b9
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:164)
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:80)
    at java_util_concurrent_Callable$call$0.call(Unknown Source)
    at org.ajoberstar.grgit.operation.PushOp.call(PushOp.groovy:114)
    ... 109 more
Caused by: org.eclipse.jgit.errors.TransportException: git@git:server/store: UnknownHostKey: git. RSA key fingerprint is f7:ac:7a:bb:62:3f:1e:cc:66:6d:82:63:5b:6b:7c:b9
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:159)
    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:157)
    ... 112 more
Caused by: com.jcraft.jsch.JSchException: UnknownHostKey: git. RSA key fingerprint is f7:ac:7a:bb:62:3f:1e:cc:66:6d:82:63:5b:6b:7c:b9
    at com.jcraft.jsch.Session.checkHost(Session.java:787)
    at com.jcraft.jsch.Session.connect(Session.java:342)
    at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:116)
    ... 118 more

@ajoberstar
Copy link
Owner

There are some reports of UnknownHostKey issues in ajoberstar/grgit#82. I think it should use your normal known_hosts file, but that issue indicates that it doesn't for some people.

@eupestov
Copy link

It is not always convenient to add the fingerprint to known_hosts (for example if you build server is expendable and tho only constant is its URL). There is a workaround exists:
com.jcraft.jsch.JSch.setConfig 'StrictHostKeyChecking', 'no'

@ajoberstar
Copy link
Owner

I'll consider this a grgit enhancement then. Follow ajoberstar/grgit#95 for progress on resolution.

@ajoberstar
Copy link
Owner

For some reason these comments aren't appearing in the issue history, so
I'll reply via email. Yes, you can force a specific auth mechanism using
the properties mentioned in AuthConfig --
http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/auth/AuthConfig.html

I haven't looked into the hostkey check yet, but plan to do so when I get
some time. I've been noticing some of the prompts on Windows as well.

On Thu, Feb 18, 2016 at 1:30 PM Bruce Edge notifications@github.com wrote:

Maybe this is a red herring as reverting back to 1.3.2 does not correct
the problem.

Is there some mechanism to force an specific git authentication mechanism?


Reply to this email directly or view it on GitHub
#145 (comment)
.

@bedge
Copy link
Author

bedge commented Feb 19, 2016

Thanks Andrew.

It is odd that only this push one action appears to use different authentication than every other grgit action I’m doing.
Rather than forcing the auth on this one item, it’d be nice to know why it’s different than the rest.

-Bruce

From: Andrew Oberstar notifications@github.com
Reply-To: ajoberstar/gradle-git reply@reply.github.com
Date: Thursday, February 18, 2016 at 5:31 PM
To: ajoberstar/gradle-git gradle-git@noreply.github.com
Cc: Bruce Edge bruce.edge@gmail.com
Subject: Re: [gradle-git] Authentication failing when attempting origin push when run inside a jenkins job (#145)

For some reason these comments aren't appearing in the issue history, so
I'll reply via email. Yes, you can force a specific auth mechanism using
the properties mentioned in AuthConfig --
http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/auth/AuthConfig.html

I haven't looked into the hostkey check yet, but plan to do so when I get
some time. I've been noticing some of the prompts on Windows as well.

On Thu, Feb 18, 2016 at 1:30 PM Bruce Edge notifications@github.com wrote:

Maybe this is a red herring as reverting back to 1.3.2 does not correct
the problem.

Is there some mechanism to force an specific git authentication mechanism?


Reply to this email directly or view it on GitHub
#145 (comment)
.


Reply to this email directly or view it on GitHub.

@ajoberstar
Copy link
Owner

Is there something in the logs indicating that the other operations are
using a different mechanism? The push may appear to be different since it's
the only one that requires write access to the repository

On Thu, Feb 18, 2016 at 7:37 PM Bruce Edge notifications@github.com wrote:

Thanks Andrew.

It is odd that only this push one action appears to use different
authentication than every other grgit action I’m doing.
Rather than forcing the auth on this one item, it’d be nice to know why
it’s different than the rest.

-Bruce

From: Andrew Oberstar notifications@github.com
Reply-To: ajoberstar/gradle-git reply@reply.github.com
Date: Thursday, February 18, 2016 at 5:31 PM
To: ajoberstar/gradle-git gradle-git@noreply.github.com
Cc: Bruce Edge bruce.edge@gmail.com
Subject: Re: [gradle-git] Authentication failing when attempting origin
push when run inside a jenkins job (#145)

For some reason these comments aren't appearing in the issue history, so
I'll reply via email. Yes, you can force a specific auth mechanism using
the properties mentioned in AuthConfig --

http://ajoberstar.org/grgit/docs/groovydoc/org/ajoberstar/grgit/auth/AuthConfig.html

I haven't looked into the hostkey check yet, but plan to do so when I get
some time. I've been noticing some of the prompts on Windows as well.

On Thu, Feb 18, 2016 at 1:30 PM Bruce Edge notifications@github.com
wrote:

Maybe this is a red herring as reverting back to 1.3.2 does not correct
the problem.

Is there some mechanism to force an specific git authentication
mechanism?


Reply to this email directly or view it on GitHub
<
#145 (comment)

.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#145 (comment)
.

@bedge
Copy link
Author

bedge commented Feb 19, 2016

Hmm, good point on the push aspect being different. All other operations are on the local repo. The push is the only one that forces an operation on the remote.
This would indicate a problem with authentication with the remote, which is a github repository.

I'm not using any explicit authentication, and I just use:

        def repo = Grgit.open(project.file('.'))

to get a repo instance.

Do I need to specify authentication options for remote repo operations?

The link you mentioned, for AuthConfig, states:

    Hardcoded credentials, if provided.
    Ssh-Agent, if available.
    Pageant, if available.
    Interactive credentials, if needed.

To me this implies that hard-coded, ssh-agent, and pagent have all been tried and failed before it resorts to putting up a dialog box for interactive credentials.

The git credentials are ssh based and github does have the public key tied to the account. IOW all git shell operations do not require a prompt.

I've gone back to catching the error around the push and simply doing a 'git push' from the shell after the task completes.
It's not the cleanest option as one has to expect the push failure and do it manually. I'd love to get the authenticated push working from within the script.

@ajoberstar
Copy link
Owner

Yes, the logic is basically as follows, and any of the options can be disabled:

  • If ssh-agent is running and it has key(s) loaded, it is used
  • Else if Pageant is running and it has key(s) loaded, it is used
  • Else if hardcoded credentials were provided those are used
  • Else prompts for interactive credentials, as needed

Are you using either of the agent based approaches? Or is there something else caching your credentials when you use the Git CLI?

@bedge
Copy link
Author

bedge commented Feb 20, 2016

I'm using ssh based URLs for the repos, eg:

git@github.com:/Company/repo-name

and my public key is registered with github, as this works on OSX & Linux identically.
ssh agent is running but has no keys registered with it.

@ajoberstar
Copy link
Owner

Maybe try setting this system property to specify exactly which key to use:

org.ajoberstar.grgit.auth.ssh.private=<path.to.private.key>

@ajoberstar ajoberstar modified the milestones: 1.5.0, wishlist Apr 12, 2016
@jtbigwoo
Copy link

jtbigwoo commented Aug 5, 2016

@ajoberstar @bedge I may have stumbled upon a work-around for this issue. Perhaps you already know about this, but when I encountered this problem, it was because my known_hosts file had an ECDSA key in it while jsch wants an RSA key. I had to delete the ECDSA key from known_hosts and add the RSA key. Here are a couple stackoverflow answers that helped me understand: http://stackoverflow.com/a/15314924 http://stackoverflow.com/a/34478483

@ajoberstar
Copy link
Owner

That's good to know. I wonder if the newer versions of JSch (grgit currently uses 0.1.49), which mention ecdsa, might fix this.

@bedge
Copy link
Author

bedge commented Mar 10, 2017

As a summary, it's basically because the default auth for github is not working.
Make sure that you have ssh auth setup for github, and have the key loaded in to your ssh keys via ssh-add.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants