Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugging "Error: Jenkins Response: No git jobs using repository" #147

Open
roxspring opened this issue Aug 17, 2015 · 25 comments

Comments

Projects
None yet
@roxspring
Copy link

commented Aug 17, 2015

Over the last month our nicely working setup has deteriorated and no longer triggers Jenkins jobs from Stash, even after upgrading to v2.7.1. When we attempt to trigger jenkins from the webhook configuration check, it reliably results in an error saying "Error: Jenkins response: No git jobs using repository: ssh://git@stash.example.com:8999/project/repo.git and branches:".

This is puzzling because there very clearly are git jobs using that repository.

But the stash log doesn't offer any extra insight into what exactly was attempted and therefore why it might have failed, and I can't identify anything obvious in the Jenkins logs either.

So what's going wrong here? And assuming the answer isn't obvious, how do I debug and figure it out?

@roxspring

This comment has been minimized.

Copy link
Author

commented Aug 18, 2015

Turns out the underlying problem was that pollSCM had been disabled on the Jenkins jobs and therefore the plugin doesn't consider those jobs. The error message is misleading though and I'm still unclear how I was supposed to figure this out.

@mikesir87

This comment has been minimized.

Copy link
Contributor

commented Aug 25, 2015

What version of the Git plugin are you using in Jenkins?

@gaeste

This comment has been minimized.

Copy link

commented Sep 29, 2015

@roxspring thanks! Glad I reached your post in due time - I was about to go berserk ;)

@gdubicki

This comment has been minimized.

Copy link

commented Oct 7, 2015

I have had exactly the same problem as @roxspring and resolved it in exactly the same way.

I think that that error message in stash-jenkins-postreceive-webhook should be changed to reflect that the cause of the problem can also be lack of "poll SCM" setting enabled.

@jwcarman

This comment has been minimized.

Copy link

commented Feb 5, 2016

You have to check the "Poll SCM" box, but you can leave the schedule empty. Very strange, but it seems to work.

@andrewferrier

This comment has been minimized.

Copy link

commented Feb 14, 2016

+1. This seems like a confusing UI. 'Poll SCM' makes it sound like the box needs to be ticked only if you want polling to happen, but it's mandatory for pushing jobs using the notifyCommit URL also.

@ashnazg

This comment has been minimized.

Copy link

commented Feb 15, 2016

The thing about the polling is that it's not the notifier webhook's job. The webhook does not do the triggering of jobs... it simply pings Jenkins with a given repo name (and sometimes a bit of additional info in the GET url). Then it's up to Jenkins to do something with that info. It'll use the repo info to find Jenkins jobs for that repo. It's up to the job's configuration to be set to poll if you want that job to be trigger-able. When the job does its poll back to Stash, that's when it decides if it has a new commit to run a build against.

Remember, this plugin is installed in Stash, not in Jenkins... it's up to the Jenkins job to be configured correctly in order to utilize what the plugin is passing to it :-)

@rajah1313

This comment has been minimized.

Copy link

commented Mar 22, 2016

we have a corner case i guess where even after following all the above setup instructions we are seeing a break of functionality with the following error

Error: Jenkins response: No git jobs using repository: ssh://git@xxxx.com/tesc/ab.git and branches: develop No Git consumers using SCM API plugin for: ssh://git@xxxx.com/tesc/ab.git

In Bitbucket the default branch is setup as develop but the branch to build in Jenkins configuration is user/abc/jira-1234

i am able to get the build to trigger from Trigger Jenkins on the bitbucket jenkins configuration to work by changing the default branch in bitbucket to user/abc/jira-1234.

clearly above is not a choice for us since we would like to keep the default branch as develop and the decided naming convention.

also another way to get around this is to change the bitbucket web hook config to say omit branch name but that just triggers builds on the default develop branch in Jenkins, not the one which is of the type user/abc/jira-1234.

Thank you very much in advance for your help and the plugin any help is really appreciated.

@rajah1313

This comment has been minimized.

Copy link

commented Apr 4, 2016

any updates ?

@bastelfreak

This comment has been minimized.

Copy link

commented Jul 8, 2016

Hi,
I've the exact same issue as @rajah1313 reported. Is it possible to get any progress here?

@NitroPye

This comment has been minimized.

Copy link

commented Sep 20, 2016

Running into this as well for Multibranch Pipeline projects. There is no "Poll SCM" option that Im aware of. Not sure how to proceed.

@kevcodez

This comment has been minimized.

Copy link

commented Dec 1, 2016

Using a Bitbucket Team Project. I added the SCMTrigger to my pipeline, still getting the same exception.

@RishabhTayal

This comment has been minimized.

Copy link

commented Dec 16, 2016

I checked the omit branch name option and it works.

@jlschrag

This comment has been minimized.

Copy link

commented Jan 9, 2017

We are having the same issue as the original post. Our jobs are all set to "Poll SCM". The "Omit Branch Name" option does allow it to trigger the job, but in our case, we need the branch name to be sent.

@ryandavis84

This comment has been minimized.

Copy link

commented Jan 12, 2017

Also having this issue

@kevcodez

This comment has been minimized.

Copy link

commented Mar 5, 2017

My Bitbucket project key is TSU. When setting up Bitbucket Server Webhook To Jenkins, it automatically generated the following URL

https://<bitbucket-server>/scm/tsu/<my-repo>.git

This did not work. Due to case-sensitivity.

I explicitly defined the project URL, by selecting the Custom option on Repo Clone URL, like this:
https://<bitbucket-server>/scm/TSU/<my-repo>.git

It worked...

@samsixtyone

This comment has been minimized.

Copy link

commented Apr 16, 2017

is this only works for "master" branch, unable to get it working for any other branch e.g "develop"

@kuniaki

This comment has been minimized.

Copy link

commented Jun 6, 2017

I run into this issue when setting BitBucket - Jenkins job.
NOTE1: Jenkins Job ( I use BitBucket Team/Project and Multibranch Pipeline for this testing)
NOTE2: I was not able to use Poll SCM option workaround, since the team/project or Multibranch Pipeline doesn’t have the option

I debugged this and it turned out the issue is coming from “git plugin” in my debug environment.
(Jenkins “git plugin” code - https://github.com/jenkinsci/git-plugin )

In my local environment, this issue is solved after fixing the code.
Jenkins Multibranch(or BitBucket team/project) job is triggered when dev pushes the code or send “pull request”.

I did the following locally.

When sending webhook to Jenkins, “doNotifyCommit” in the GitStatus class is the entry point and
it executes  “onNotifyCommit” function in the same class.   

My understanding is that "onNotifiCommit function in the GitStatus class" doesn’t support multibranch workflow. Therefore, I introduced the following function.

private List onMultibranchJob(URIish uri,Jenkins jenkins,List result)
{
for (final Item project : Jenkins.getInstance().getAllItems()) {
SCMTriggerItem scmTriggerItem = SCMTriggerItem.SCMTriggerItems.asSCMTriggerItem(project);
if (scmTriggerItem == null) {
String projectName = project.getFullDisplayName();
String [] jobs = projectName.split(" » ");
if(uri.toString().toLowerCase().contains(jobs[jobs.length-1].toLowerCase())) {
String className = project.getClass().getSimpleName();
if(className.equals("WorkflowMultiBranchProject")) {
try {
WorkflowMultiBranchProject wmp = (WorkflowMultiBranchProject) project;
wmp.scheduleBuild2(0);
result.add(new ScheduledResponseContributor(project));
} catch (Exception e) {
e.printStackTrace();
}
}

}
}
}
return result;
}

And, in the onNotifyCommit function, I added the following to support Muitlbranch job.
result = onMultibranchJob(uri,jenkins,result);
if(result.size() !=0)
return result;

Git Plugin” project doesn’t have “WorkflowMultiBranchProject” dependency definition.
Therefore, I needed to define the dependency in the project.

In my local environment, BitBucket - JenkinsJob(MultiBranch or BitBucket Team Project) is working fine with this fixing.

I recently joined DevOps job and I am very beginner for this type of setting.
So I may miss something basic. Please advice me.

@kuniaki

This comment has been minimized.

Copy link

commented Jun 7, 2017

I forked the git plugin repo and submitted the code onto https://github.com/kuniaki/git-plugin.

Instruction:

  1. Clone code
    git clone https://github.com/kuniaki/git-plugin.git
  2. cd git-plugin
  3. Build
    mvn package (if you like to skip the testing, mvn package -DskipTests)
  4. Install hpi file to Jenkins
    You can find git.hpi in the git-plugin/target folder
    Go to Jenkins -> Manage Jenkins -> Manage Plugins -> Advanced.
    Click on “Choose File” button in the “Upload Plugin” and select the git.hpi file
    Click on “Upload” button.
    Start the installation.
    Please check “Restart Jenkins when installation is complete and no jobs are running"

In my environment, I don’t see the webhook error.

NOTE: I verified BitBucket webhook behavior. I don't test GitHub,GitLab etc....

@sentinel09

This comment has been minimized.

Copy link

commented Jun 27, 2017

I am using pipeline and Bitbucket does not trigger new build.
I have configured Jenkins hook and Jenkins webhook, as well as have pollSCM('') directive in my pipeline.
Trying to trigger build from bitbucket receive such errors:
Error: Jenkins response: No git jobs using repository: blablabla
No Git consumers using SCM API plugin for: blablabla

@ralcr

This comment has been minimized.

Copy link

commented Jul 28, 2017

I had the same problem, i'm just learning and I tried to call my local repository url but on jenkins was set the remote repository. I changed the hook to call the remote url and it works but i have the same "No Git consumers using SCM API plugin for:" stuff, curious what it is..

@hax0rdlux3

This comment has been minimized.

Copy link

commented Nov 2, 2017

It has to do with your specified Branch -

Branches to build Branch Specifier (blank for 'any')

if you set it to 'blank' or 'any' it works... I have been annoyed by this all morning.

@menicolas89

This comment has been minimized.

Copy link

commented Feb 6, 2018

@hax0rdlux3 I was told the same, but managed to make it work for a specific branch so this seems to not be the only way to fix. Also from design perspective :what if the job only concerns a specific branch only?
For another project I am still not able to make it work (with branch a specific branch name) , it is annoying as the only difference I can see is the project and branch name.

@sentinel09

This comment has been minimized.

Copy link

commented Feb 6, 2018

Well, I made this workable.
All our Bitbucket repositories are configured to build through Jenkinsfiles.
In Jenkins I was configuring by adding these repositories as Bitbucket/Team project and and add "Override hook management". Do not forget to remove pollSCM('') from your Jenkinsfiles as it's excess in this hook strategy.
After adding projects, repositories and branches, Jenkins will scan for repositories and adding them to system. Jenkins also itself will register hook in Bitbucket (Post webhooks) like https://your-jenkins.url/bitbucket-scmsource-hook/notify, which options you can change in Bitbucket for every repository.
So using this strategy, will provide you build triggering, automatic repository addition (I can clarify details if need).

@dibbles

This comment has been minimized.

Copy link

commented Jun 28, 2018

One point to note that may help others ..... go careful with the Payload URL on your webhook, one gotcha I've noticed is that there is some case sensitivity involved with Jenkins.

A payload URL of :
https://jenkins.at.my.url/git/notifyCommit?url=https://github.corporate.com/foo/sample.git

would not trigger a multibranch pipeline with a git url of https://github.corporate.com/FOO/sample.git

Annoyingly the git webhook status is 200 in both working and non working cases, but in the broken case I saw the response body stating:

No git jobs using repository: https://github.corporate.com/foo/sample.git and branches:
No Git consumers using SCM API plugin for: https://github.corporate.com/foo/sample.git

but in the working case the response body is:

No git jobs using repository: https://github.corporate.com/foo/sample.git and branches:
Scheduled indexing of default ? jenkinsjobname

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.