Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-38454

NPE thrown while configuring github pull request trigger on a pipeline

      I am trying to create a Pipeline job for a github project and while configuring the Build Trigger with a Build Github Pull Request the Save is causing a NPE.

      In the pipeline I have provided the git project URL and PR trigger with a Cron tabline of '* * * * *' and trigger mode 'CRON with persisted data'. I tried varying the trigger mode and cron tabline settings but I always get the NPE.

      As an experiment, I created a new Freestyle project and I noticed that for the style of project one is presented with the 'Source Code Management' block where one picks the repo and credentials, as well as the git project URL and the githhub pull request parameters. I am able to save that project.

      For the pipeline job the git repo is being clone in the pipeline code.

          [JENKINS-38454] NPE thrown while configuring github pull request trigger on a pipeline

          Pete Hale created issue -
          Pete Hale made changes -
          Epic Link New: JENKINS-31152 [ 165808 ]
          Andrew Bayer made changes -
          Epic Link Original: JENKINS-31152 [ 165808 ]

          Andrew Bayer added a comment -

          Can you attach the Pipeline script that's failing so we can reproduce this? Thanks.

          Andrew Bayer added a comment - Can you attach the Pipeline script that's failing so we can reproduce this? Thanks.
          Andrew Bayer made changes -
          Component/s New: workflow-job-plugin [ 21716 ]
          Component/s Original: pipeline [ 21692 ]

          Kanstantsin Shautsou added a comment - - edited

          I think script not need because it only how Trigger.start(job, boolean) is called. My code contains check to ensure that job is passed with right trigger and NPE caused by trigger missing in job. I can rework code, but would firstly like to see some javadoc about initialisation order that worked fine before.

          Kanstantsin Shautsou added a comment - - edited I think script not need because it only how Trigger.start(job, boolean) is called. My code contains check to ensure that job is passed with right trigger and NPE caused by trigger missing in job. I can rework code, but would firstly like to see some javadoc about initialisation order that worked fine before.

          Andrew Bayer added a comment -

          Ok, I found the problem - GitHubPRTrigger.start needs the trigger to be returned from Job.getTriggers() or it barfs out, but with the JobProperty approach in WorkflowJob, Trigger.start is called in PipelineTriggersJobProperty.rebuild, which is run before Job.doConfigSubmit actually calls properties.add(someProperty)...so Job.getTriggers() doesn't include the GitHubPRTrigger on first save. Woof. That's...complicated and painful. I'll see what I can figure out.

          Andrew Bayer added a comment - Ok, I found the problem - GitHubPRTrigger.start needs the trigger to be returned from Job.getTriggers() or it barfs out, but with the JobProperty approach in WorkflowJob , Trigger.start is called in PipelineTriggersJobProperty.rebuild , which is run before Job.doConfigSubmit actually calls properties.add(someProperty) ...so Job.getTriggers() doesn't include the GitHubPRTrigger on first save. Woof. That's...complicated and painful. I'll see what I can figure out.
          Andrew Bayer made changes -
          Assignee New: Andrew Bayer [ abayer ]
          Pete Hale made changes -
          Attachment New: test-dh-git-status.zip [ 34055 ]

          Pete Hale added a comment -

          I have attached the zip of the job that is getting the NPE. I did try to recreate the issues with a scratch Pipeline job and I did not see the NPE, so I have a workaround. The job is barebones. For me, when I go to config the job, click on Github Pull Request in trigger and and a cron of '* * * * *', then save. This is where the NPE happens for me.

          Pete Hale added a comment - I have attached the zip of the job that is getting the NPE. I did try to recreate the issues with a scratch Pipeline job and I did not see the NPE, so I have a workaround. The job is barebones. For me, when I go to config the job, click on Github Pull Request in trigger and and a cron of '* * * * *', then save. This is where the NPE happens for me.

            abayer Andrew Bayer
            peternhale Pete Hale
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: