jenkinsci / ghprb-plugin

github pull requests builder plugin for Jenkins
https://plugins.jenkins.io/ghprb/
MIT License
501 stars 608 forks source link

How to trigger Jenkins CI with a bot using ghrb plugin #769

Open ChaiBapchya opened 4 years ago

ChaiBapchya commented 4 years ago

I'm trying to build a bot that would trigger the Jenkins CI usingg ghrb plugin?

So the bot will look for a specific string & if it comes from a set of people and only then will it trigger CI using the ghrb plugin

Currently, ghrb plugin runs for all PRs created against master branch. How should I configure the ghrb plugin so that my bot can call it?

ChaiBapchya commented 4 years ago

@bjoernhaeuser

  • only trigger builds for PRs manually (you have to set the triggers accordingly)

@bjoernhaeuser Can you please point to how to do that?

Originally posted by @ChaiBapchya in https://github.com/jenkinsci/ghprb-plugin/issues/666#issuecomment-593072510

That comment was in reference to this issue I am facing.

I have Jenkins plugins setup (GitHub, GitHub branch source, GHPRB) Currently, we have following rules for our jobs

Screen Shot 2020-03-01 at 1 07 31 AM

This translates into a CI run automatically for every new PR made (and subsequent commits pushed in that PR)

Context : Manual CI trigger (instead of existing automated CI trigger)

Usecase: I have a AWS lambda bot that a. looks if the bot is called b. checks if the comment author c. if verified only then I want to invoke the build (not automatically for every build)

In such a scenario what should be my rules? If I turn off discovering PRs then I am unable to trigger the build using Jenkins API It gives an error saying

Traceback (most recent call last):
  File "build_jenkins.py", line 69, in <module>
    jenkins_obj.build_job(job_name)
  File "build_jenkins.py", line 28, in build_job
    job = self.jenkins_server[name]
  File "/Users/bapac/Downloads/jenkins/lib/python3.7/site-packages/jenkinsapi/jenkins.py", line 269, in __getitem__
    return self.jobs[jobname]
  File "/Users/bapac/Downloads/jenkins/lib/python3.7/site-packages/jenkinsapi/jobs.py", line 89, in __getitem__
    raise UnknownJob(job_name)
jenkinsapi.custom_exceptions.UnknownJob: 'mxnet-validation/apache-centos-gpu/14'