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

NPE in abortRunningJobsThatMatch #13

Open
jlongman opened this issue Sep 26, 2018 · 1 comment
Open

NPE in abortRunningJobsThatMatch #13

jlongman opened this issue Sep 26, 2018 · 1 comment
Labels

Comments

@jlongman
Copy link

Hi, love the plugin, it's awesome. Thank you.

I am running BBPRB v.0.3.0 on Jenkins v.2.121.2.

I recently converted a job from a normal build to a pipeline workflow - it allows easier access to doing programmatic search for ambiguously defined dependencies (sigh). Ie I can search other builds to find products of a similarly named branch in a separate repo.

Unfortunately now when I do this I now get stack traces in my jenkins backend when the job should be triggered:

WARNING: Error while serving https://jenkins.protmv.com/bbprb-hook/
java.lang.reflect.InvocationTargetException
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:347)
[...]
Caused by: java.lang.NullPointerException
	at org.jenkinsci.plugins.bbprb.BitbucketBuildTrigger.abortRunningJobsThatMatch(BitbucketBuildTrigger.java:214)
	at org.jenkinsci.plugins.bbprb.BitbucketBuildTrigger.startJob(BitbucketBuildTrigger.java:156)
	at org.jenkinsci.plugins.bbprb.BitbucketBuildTrigger.handlePR(BitbucketBuildTrigger.java:282)
	at org.jenkinsci.plugins.bbprb.BitbucketHookReceiver.doIndex(BitbucketHookReceiver.java:108)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
[...]

Looking at the code there (Note, I've added the WARNING logging):

  private void
  abortRunningJobsThatMatch(@Nonnull BitbucketCause bitbucketCause) {
    logger.log(Level.FINE, "Looking for running jobs that match PR #{0}",
               bitbucketCause.getPullRequestId());
\\    logger.log(Level.WARNING, "job: " + (job != null? job.toString() : "null - no job"));
\\    logger.log(Level.WARNING, "job-builds: " + (job.getBuilds() != null? job.getBuilds().toString() : "null - no jobbuilds"));
    for (Object o : job.getBuilds()) {
      if (o instanceof Run) {
        Run build = (Run)o;
        if (build.isBuilding() &&
            hasCauseFromTheSamePullRequest(build.getCauses(), bitbucketCause)) {

the logging shows the this.job is null.

It looks like WorkflowJob does not have AbstractProject as an ancestor, and maybe this explains this behaviour in some weird way. A quick search shows this seems to be on "purpose".

I looked at quickly adding something that would work but realized that my first thought of checking types in startJob for ParameterizedJob would fail as scheduleBuild2 there lacks the necessary signature.

I don't understand why this.jobs is null in that later method so I'm pretty sure I don't understand what's going on.

Am I missing something?

@ip1981
Copy link
Owner

ip1981 commented Sep 26, 2018

Thank you. I haven't used this plugin with pipeline yet, but will take a look.

@ip1981 ip1981 added the bug label Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants