mohamicorp / stash-jenkins-postreceive-webhook

Webhook used to notify Jenkins when commits are made to Stash
Other
138 stars 98 forks source link

commit notification null #134

Closed danalbu closed 8 years ago

danalbu commented 9 years ago

I am getting this error if i manually trigger the plugin from stash without this options turned on: Omit SHA1 Hash Code Omit Branch Name System: Jenkins 1609.1 Git plugin 2.3.5 Stash Jenkins Webhook plugin 2.7.0 Stash Server version 3.6.0

I am basically having 2 jobs identical, only the branches name is different: one is "master" the other one "release"

The error from Jenkins console:

commit notification null 00:00:00.027 [EnvInject] - Loading node environment variables. 00:00:00.037 Building remotely on \ (automation 10xwindows) in workspace C:\jenkins\workspace\StashJobTriggerBranch 00:00:00.090 > C:\jenkins\tools\git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10 00:00:00.106 Fetching changes from the remote Git repository 00:00:00.110 > C:\jenkins\tools\git\bin\git.exe config remote.origin.url ssh://***.git # timeout=10 00:00:00.130 Fetching upstream changes from ssh://**_*****.git 00:00:00.132 > C:\jenkins\tools\git\bin\git.exe --version # timeout=10 00:00:00.145 > C:\jenkins\tools\git\bin\git.exe -c core.askpass=true fetch --tags --progress ssh://******.git +refs/heads/:refs/remotes/origin/* 00:00:04.745 > C:\jenkins\tools\git\bin\git.exe rev-parse "null^{commit}" # timeout=10 00:00:04.764 FATAL: Command "C:\jenkins\tools\git\bin\git.exe rev-parse "null^{commit}"" returned status code 128: 00:00:04.764 stdout: null^{commit} 00:00:04.764 00:00:04.764 stderr: fatal: ambiguous argument 'null^{commit}': unknown revision or path not in the working tree. 00:00:04.764 Use '--' to separate paths from revisions, like this: 00:00:04.764 'git [...] -- [...]' 00:00:04.764 00:00:04.764 hudson.plugins.git.GitException: Command "C:\jenkins\tools\git\bin\git.exe rev-parse "null^{commit}"" returned status code 128: 00:00:04.765 stdout: null^{commit} 00:00:04.765 00:00:04.765 stderr: fatal: ambiguous argument 'null^{commit}': unknown revision or path not in the working tree. 00:00:04.765 Use '--' to separate paths from revisions, like this: 00:00:04.765 'git [...] -- [...]' 00:00:04.765 00:00:04.765 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1591) 00:00:04.765 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1567) 00:00:04.765 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1563) 00:00:04.765 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1249) 00:00:04.765 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1261) 00:00:04.765 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.revParse(CliGitAPIImpl.java:622) 00:00:04.765 at hudson.plugins.git.GitAPI.revParse(GitAPI.java:316) 00:00:04.765 at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source) 00:00:04.765 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 00:00:04.765 at java.lang.reflect.Method.invoke(Method.java:601) 00:00:04.765 at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299) 00:00:04.765 at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280) 00:00:04.765 at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:239) 00:00:04.765 at hudson.remoting.UserRequest.perform(UserRequest.java:118) 00:00:04.765 at hudson.remoting.UserRequest.perform(UserRequest.java:48) 00:00:04.765 at hudson.remoting.Request$2.run(Request.java:328) 00:00:04.765 at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) 00:00:04.765 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) 00:00:04.765 at java.util.concurrent.FutureTask.run(FutureTask.java:166) 00:00:04.765 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) 00:00:04.765 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) 00:00:04.765 at hudson.remoting.Engine$1$1.run(Engine.java:63) 00:00:04.765 at java.lang.Thread.run(Thread.java:722) 00:00:04.765 at ......remote call to oo10.x_node2(Native Method) 00:00:04.766 at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1360) 00:00:04.766 at hudson.remoting.UserResponse.retrieve(UserRequest.java:221) 00:00:04.766 at hudson.remoting.Channel.call(Channel.java:753) 00:00:04.766 at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:179) 00:00:04.766 at com.sun.proxy.$Proxy50.revParse(Unknown Source) 00:00:04.766 at org.jenkinsci.plugins.gitclient.RemoteGitImpl.revParse(RemoteGitImpl.java:546) 00:00:04.766 at hudson.plugins.git.RevisionParameterAction.toRevision(RevisionParameterAction.java:85) 00:00:04.766 at hudson.plugins.git.GitSCM.determineRevisionToBuild(GitSCM.java:903) 00:00:04.766 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1017) 00:00:04.766 at hudson.scm.SCM.checkout(SCM.java:484) 00:00:04.766 at hudson.model.AbstractProject.checkout(AbstractProject.java:1270) 00:00:04.766 at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:609) 00:00:04.766 at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) 00:00:04.766 at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:531) 00:00:04.766 at hudson.model.Run.execute(Run.java:1741) 00:00:04.766 at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:537) 00:00:04.766 at hudson.model.ResourceController.execute(ResourceController.java:98) 00:00:04.766 at hudson.model.Executor.run(Executor.java:374) 00:00:04.772 Finished: FAILURE

danalbu commented 9 years ago

Also if i commit to master and branch separatly only the master job will build. The branch job doesn't receive the notification from Stash to build:(

markottaviani commented 9 years ago

I'm encountering the same issue

mikesir87 commented 9 years ago

Thanks for the issue and sorry for the slow response. You're getting this when triggering manually. Is this on the pull request page or through the webhook settings page (the test button)? Just want to make sure I'm looking at the right spot.

In this case, what would you like to happen? I would figure that if the hash is null, don't bother sending it. But, not sure if, in this case, there's a hash that should be sent but is somehow getting null instead.

danalbu commented 9 years ago

NP Mike. I am glad at least you take our issues into consideration. The problem occurs when triggered manually in my case from the test button. What i would like it to happen is that the jobs will get triggered automatically and send the hash to the jenkins master. For example i have a project that i have 3 jobs. 1 for master and 2 for branches were i do hotfixes. If i commit to the branch i would like theat branch job to receive the correct hash and start a build.

ashnazg commented 9 years ago

IIRC, when you push the Test button on the settings page, only the repo name gets passed, since it was not a specific commit on a specific branch that was the "trigger". Thus, when Jenkins receives the signal with only the repo name, only jobs configured on a matching repo and set to "poll scm" will be launched. In this case, even the branch specifiers on the jobs won't stop the poll, though of course if the poll retrieves a commit# from Stash that the job knows it's already built, it will stop at that point.

In the case of a master commit triggering the master build ok but a release commit does not trigger the release build, is the release job set to poll (no schedule necessary, but polling must be enabled) and specifically configured to watch the release branch? The Jenkins log itself should show the incoming notification from Stash, even if it doesn't result in launching a build job.

davidkarlsen commented 9 years ago

Any solution for this? Would it be sensible to omit branch and sha1 when pushing the testbutton (as this is actually the case). Or additionally a "test-advanced" button which prompts/lists branches/commits?

bmoyles commented 9 years ago

We ran into this as well. Jenkins received ?url=ssh%3A%2F%2Fgit%40scm-server.hostname.net%2Fprojectname%2Freponame.git&sha1=null

per the access logs on our instance. When omit SHA is not checked, and the build is triggered from the repository config, I would expect one of two things to happen: a bare notifyCommit with just the repo is sent, or, the SHA for the HEAD of the default branch for the repository would be sent.