执行push命令时捕获到异常

时间:2016-05-03 11:41:23

标签: gradle grgit

我有一个任务:

task tagRepo1 << {
logger.info("adding tag in the repo")

def buildNumber = '545'
if (!buildNumber) {
    // not to be executed outside build system
    throw new Exception('tagRepo should only be executed via build, no build number found')
}

def gitTagName = 'tag1'
if (!gitTagName) {
    throw new Exception('gitTagName is not set')
}

def gitTagMessage = 'someMessage'
if (!gitTagMessage) {
    // default message
    gitTagMessage = 'default tagging message'
}

def gitUserName = 'user'
if (!gitUserName) {
    throw new Exception('gitUserName is not set')
}

 def gitPassword = 'password'
if (!gitPassword) {
    throw new Exception('gitPassword is not set')
}

def credentials = new org.ajoberstar.grgit.Credentials(gitUserName,gitPassword)

def grgit = org.ajoberstar.grgit.Grgit.open(dir: project.rootDir.absolutePath, creds: credentials)

def remotes = grgit.remote.list()
logger.info('git remotes size - ' + remotes.size())
logger.info('git remotes - ' + remotes)

def central = remotes.find { it.name == 'central' }
if (!central) {
    def gitRepoLocation = 'location'

    if (!gitRepoLocation) {
        throw new Exception('gitRepoLocation is not set')
    }

    grgit.remote.add(name: 'central', url: gitRepoLocation)
}

grgit.tag.add(name: gitTagName, message: gitTagMessage)
grgit.push(remote: 'central', tags: true)
}

但是当我执行此任务时,我在推送标签时出错 Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of push command。任何想法为什么会出现这个问题

如果我--stacktrace,我会得到这个输出:

*Exception is:
 org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':core:tagRepo1'.
    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: org.eclipse.jgit.api.errors.JGitInternalException: Exception  caught during execution of push command
    at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:178)
    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)
    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 build_5ti1avic8c4zg9l8osnwfpqdj$_run_closure3.doCall(C:\Users\Byteorigin\Documents\corepro\core\build.gradle:264)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:548)
    at org.gradle.api.internal.AbstractTask$ClosureTaskAction.execute(AbstractTask.java:529)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:77)
    at org.gradle.api.internal.tasks.TaskMutator$1.execute(TaskMutator.java:73)
    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
Caused by: org.eclipse.jgit.errors.NotSupportedException: remote does not support smart HTTP push
    at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:398)
    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)
    ... 62 more

1 个答案:

答案 0 :(得分:1)

使用-i-d开始gradle,以获得有关查找最终原因的更多信息。另外或者添加-s以获取显示的catched异常的完整堆栈跟踪,以找到问题的根本原因。如果您在此之后仍需要帮助,请将检索到的更多信息添加到您的问题中。

<强>更新
好吧,正如您的完整堆栈跟踪显示的那样,您的远程配置了HTTP URL,但Git服务器不支持通过HTTP进行推送,而HTTP必须明确启用。因此,您不能将任何内容推送到此远程,而不仅仅是grgit创建的标记。使用git remote --set-url <url>将您的远程网址更改为支持ssh:git:网址推送的网址,具体取决于您尝试使用的Git服务器。