Open antoine-morisseau opened 9 years ago
And i checked into the repository in the hooks folder i don't find anything that can be related to the plugin. Where do you execute you plugin after a push ? i check a the post-receive file and there is nothing related to jenkins.
By the way Stash and git are on a windows server.
Nevermind. it works... It's jenkins that is fucked up. Spent one week to tried to create one job for one repo that allow manual build of selected branch from user and dynamic build through commit. that cannot be done since the git plugin in jenkins if we put a parameter simply cannot correctly pull the branche selected or that branche that trigger the hook....
:) welp... glad to help out! Let me know if you run into anything else.
Thanks ! Well i fixed my issue by getting the last update of git-plugin in Jenkins (v2.3.1). But now i still have the issue. Is there a way to get the log when the notifyCommit is done ? Because i activated debug mode in stash and i don't see it... Because now i fixed my issue in jenkins but the webhook does nothing. It doesn't work if in a job i set in the Branche Specifier slot a variable. (like /${BRANCHE} ) The polling log doesn't update when a git push is done with this variable in the slot. If i set */ for instance the git push does trigger the polling from jenkins. But if in the post-receive file i put this line :
Jenkins is triggered. So i don't know where to check. in your plugin side ? or in Jenkins side ? I would like to check both but i don't know where to look :/
Annnnd reopened !
One very simple use case to test the issue.
Create a repository on Stash. Create a job on Jenkins. set up jenkins to connect to the stash repository
set up a build parameter with variable name branches and default value is **
in Branche Specifier set the value at */${BRANCHES}
activate poll scm as usual and that's all.
go into the Git Polling log and check the log. (at this point it will have no log)
Go into your repository and configure the webhook plugin properly. Push the Trigger Jenkins button in order to test and make it display Success go back to the Git Polling Log in jenkins and you'll see the log updated.
Now with any git client go checkout the repository and create a file and push it on the repository (pretty simple stuff)
Now check out the git polling log. It will not have been updated. (it's this behaviour in my case)
If you simply modify the /${BRANCHES} to /** and save the jenkins configuration and you re push something on the repository, now you'll see that the git polling log is properly updated.
I activated the git-plugin debug log in order to see if it received any notifyCommit. It receive the notifyCommit when the Trigger Jenkins button is pushed and when the Branche Specifier is set at */**. Otherwise it detect nothing.
The only workaround i found is to go to the repository folder in the Stash server. go to the hook folder and modify the post-receive script file by adding the usual line :
Now with this line added it will trigger the notifyCommit in Jenkins even if */* is set or /${BRANCHES} is set.
I activated the debug log in Stash in order to retrieve the informations when i did a git push on the repository.
Here when the branche specifier was at */${BRANCHES} :
Here when the branche specifier was at */** :
Hope you'll find something useful !
Regards,
What document showed you to use that ${BRANCHES}
variable in the branch specifier? I've never been aware of something like being usable in the branch specifier, thus I wonder if that's why it was not working for you. The wildcard *
is usable, but I've never seen something like ${BRANCHES}
being documented as usable.
Well in the Branches specifier un jenkins if you click on the "?" button it show that you can use variable in order to verify branches from the resolved variable (text here : http://pastebin.com/XKyZ0N2D ) There was an issue on it but it was fixed saturday on git-plugin 2.3 . ( https://issues.jenkins-ci.org/browse/JENKINS-20427 and https://issues.jenkins-ci.org/browse/JENKINS-14276)
And i don't think the ${BRANCHES} have to do something in this issue since the workaround i do is very very similar of what the webhook plugin have to do or i'm missing something in this plugin.
If I understand the sequence of events correctly, then then branch matching on a job does come into play:
Thus, an incorrect/unusable branch spec on the jobs could be the reason a Stash Notify event was seen by Jenkins but ignored. Again, if I understand the sequence correctly... I always learn a bit more about the process each time I talk about it with people ;-)
Ok, that popup text seems to be describing "environment variables", thus something external to the Jenkins job config would have to specify that value. If it's not specified somewhere, then it's just empty, and thus a branch spec of */${BRANCHES}
ends up being just */
. By replacing the spec with */**
(or possibly just */*
), it would be matching any/every branch, and thus the "branch does match" hit would then do the poll step.
about the ${BRANCHES}
thing the issue that it was not resolved before. so it's generated an issue that the polling didn't work as usual.
The thing that i don't understand well that is it's working like a charm if i add curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>
in the post-receive file of the hook repository folder. And i was thinking that the webhook plugin was just doing that but it seems not.
The real issue here is to find where is the issue. Because i'm thinking that it could come from the git-plugin in jenkins that is not catching the notifyCommit that the webhook plugin sent. Or it could also come from the webhook that is not sending the notifyCommit since he check something in the jenkins url and decide to not send the notify for some reasons. (by looking at the branches specifier maybe ? )
@ashnazg So from your guess if i do something like that */*${BRANCHES}
it could work right ?
EDIT : i justed tried and same thing as usual... :/
The key to me is where that build parameter of $BRANCHES gets a value placed into it. Unless it is a standard parameter that the Git Plugin passes (like GIT_COMMIT), then it will not be a populated environment variable for the Jenkins job to read, and will thus be empty.
None of my "build should be triggered by new commits" jobs are "parameterized". The job should be configured to "watch a specific branch spec for changes" and "build this branch spec when triggered". There are two places in the job config where these two things are set up.
The first, "which branches to watch for changes", is under the Advanced button of the repository config, "refspec". I think this is what has to match the info that is included in the notification that comes from Stash when a new commit is pushed. If the notification can't match a job's refspec, then no job will poll.
The second, "which branches to build", is the "Branches to build" box that is just below the repo config. I think that the poll event uses this value here to try to pull new commits down to be built. I don't think this is used in the decision "got a notification, does it match any of my jobs?" piece... I think it is the first config value above that is used for that decision.
@mikesir87 keep me straight here ;-)
Getting back to a build parameter, the only jobs I use as parameterized builds are all On-Demand jobs, where the person initiating the job has to populate a value in each parameter. Thus, I am not aware of any parameterized build being usable as a push-triggered build.
I am having the same issue. Here is my setup:
The problem I am having is that when Jenkins job is configured to use master branch to build, the build is triggered correctly on Jenkins when code is pushed into Stash master branch. When I change the Jenkins configuration to build any other branches (feature, release etc...), build is not triggered on Jenkins when there is a push into the branch I am building from. I was wondering what I might be doing wrong here?
I also wanted to know what should be put in the text box if I chose "Build From:" option or "Ignore from" option in the Advanced section of the webhook plugin config page. For a feature branch, should I put "feature/jenkins-test" or "origin/feature/jenkins-test" or something else. Will it accept regex?
I have the same error, while manually triggering a build via Trigger Build works It doesn't work while trying to git push. I want that git push should also build every commit.. BranchSpecifier is \ (any) on jenkins, I don't know what to do
And the Stash Plugin is Build All and Omit Branches
Same issue here :(
I tried to use "master" as a branch specifier on both ends, but that did not help either.
I had the similar problem, that using the Trigger Jenkins button worked and triggered my Jenkins job but a new commit did not trigger the Jenkins job.
My problem was that I had a wrong Base URL configured in Bitbucket Server (Administration->Server settings). The Base URL configured here is used to trigger Jenkins upon a new commit, however the Trigger Jenkins test button uses the URL shown in the browser.
Hello,
i use a git project in Stash and Jenkins in order to build it. i properly configured the plugin in order to do a notifyCommit to jenkins. When i click the test trigger it say success and in jenkins i have the git polling log properly updated. So it's working right ? It seems not ! If i work in a branch of my repository and push my modification to the server. Stash properly update the commit logs. But jenkins doesn't receive any notifyCommit. it's seems that it does nothing.
i used the http connection for git at first before using the ssh method. Stash each time i pushed added a log entry in atlassian-stash-audit.log
fe80:0:0:0:8485:4b5d:3c93:89d8%10 | AuthenticationFailureEvent | amorisseau | 1417184166168 | amorisseau | {"authentication-method":"basic","error":"Nom d'utilisateur ou mot de passe invalide."} | @1ETWUW5x916x7396x0 | -
So i thought it may come from the authentication failed. so i switched to ssh and tried again. Same thing except that now i doesn't have any log into the atlassian-stash-audit.log.
I checked into the wiki for help ( https://github.com/Nerdwin15/stash-jenkins-postreceive-webhook/wiki/Debug ) and you talk about a logfile. But i don't see any logfile about your plugin...
I activated the debug and here what's happen when i trigger the test button : http://pastebin.com/zdfGj7Vs And when i do a push : http://pastebin.com/GnMnm4RN
Thoses logs comes from the atlassian-stash-access.log