Trigger build on Jenkins from Github repo - github

I've found many sites that describe how to trigger a build on a Jenkins machine whenever new code is pushed to a Github repository. One thing that keeps showing up repeatedly is to check the "Build when a change is pushed to GitHub" item under the Build Triggers section..
Unfortunately, no matter what I do I can't seem to get that item to show up as an option for me under Build Triggers.
I've even removed and re-installed Jenkins from scratch. When I install it, I just tell it to install all of the most common plugins. I've verified in the Jenkins configuration that the GitHub plugin is there.
What am I missing to trigger a build on a GitHub repo update?

According to https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin#GitHubPlugin-PluginInformation this was changed from
Build when a change is pushed to GitHub
to
GitHub hook trigger for GITScm polling
So it is sufficient to have GitHub Plugin installed.

Related

How to prevent extra build in github. Generated by git tag push

Earlier we were using the GITlab. Recently we are migrated to GITHUB. When I am commit a code in GITHUB it generating a build in jenkins via webhook push event.
But in my ansible code we are pushing a tag for the same code. It also generating a new build in jenkins with by default "build" branch name.
I need to prevent a build which is getting triggered by the tag push in jenkins. It causing a issue in our whole pipeline. Due to that we gave the optional filter for branch but It preventing our multibranching scenario.

GitHub webhook repo is unable to trigger jenkins pipeline

Our Company used to self-host GitLab for source-code management and configured webhook on gitlab to trigger all the project pipelines on jenkins. Initially, the gitlab url was 'https://git.fulcrumdigital.com' and later for an upgraded version, they changed url to 'https://autobuild.fulcrumdigital.com'
Recently, we migrated to 'github.com' and created an organization. The source codes for various projects are found under this organization, which is private. Now, when I try to configure webhooks for these projects, I see that they deliver as intended to jenkins, but jenkins doesn't trigger the respective project's build. Instead, it gives out a message as shown below.
jenkins-github webhook error
I don't find any info regarding this webhook on global configuration page.
Here is a snapshot of jenkins logs
jenkins logs
I don't face this webhook issue for newly created pipeline-projects on jenkins. I face this issue for older pipeline-projects that already had their webhook configured earlier for gitlab.
Help me to resolve this issue and make jenkins trigger build from github webhook for older pipeline-projects.
Did you try force regenerating the webhooks?
Go to Manage Jenkins > Configure System > GitHub plugin > Advance > Re-registers hooks for all jobs.
I had this problem myself. The first thing you want to do is go to Manage Jenkins -> Configure System scroll down to the GitHub section and click on "Advanced". You will see this:
It's important to have access to your Jenkins log (I'm running Jenkins with Docker). When I clicked on Re-register hooks for all jobs, I got the following error:
In my case, the error mentioned something with my access token. So, I checked my Github personal access token and it turned out, I need to turn on Read and Write for Webhook:
Now, go back to Jenkins and click on Re-register hooks for all jobs again, and on the next push, the build was automatically triggered.

Remove cloud build trigger from github checks

I had a cloud build trigger that would run tests on pull request.
Then I disabled the trigger and then deleted it. But it still shows up in Github PR. How can I remove it?
After deleting the trigger from Cloud Build, I also had to remove it from Github repository settings:

Jenkins Auto update

I have a question, Im trying to commit updates that im doing on my database to a Github, I am using redgate to setup the repository and commit the changes.
Anyway I am trying to connect Github repo to Jenkins, so whenever I commit change.
So the trigger is update one the repo, what I want is to get changes on the repo without pressing 'BUILD NOW' on Jenkins.
I already installed github plugin to Jenkins and but in the new version there is no trigger ' Build when a change is pushed to Github'.
Also I tried Web-hook but I am not really familiar with it.
Any hint or idea that might help!
and I will be thankful.
GitHub Jenkins Trigger
On the new release of the GitHub plugin, trigger Build when a change is pushed to GitHub has been renamed to GitHub hook trigger for GITScm polling. So choose this instead.
GitHub Webhook
There is a quick and good guide here about creating a webhook on GitHub and link it to your Jenkins build.
In short in GitHub navigate to :
Settings -> Webhooks & Services -> Service -> Add Services -> "Jenkins (GitHub plugin)"
Then
Enter your webhook URL in the “Jenkins hook URL” field and press “Add
service”
To test that everything has been configured correctly:
click on the created service and
press the “Test service” button in the upper right corner. If
everything is correctly configured, the Jenkins service has got a
green checkmark icon in the service overview and the build process has
started.
If there is no trigger for
' Build when a change is pushed to Github'.
Then simply downgrade the plugin version and try again.

Jenkins how to set build status on Github commit?

I have set up Jenkins and Github such that whenever I push a commit to an existing pull request, it automatically adds a comment and triggers a Jenkins build. Prior to today, Jenkins amended that comment with the status of the build and the functional tests executed. (So I know that part works.)
Today, I updated Jenkins and Jenkins ceases to notify Github of the build status. When I check the Jenkins configuration, the post-build section says:
Set build status on Github commit [deprecated]
This notifier will set GH commit status. This step is DEPRECATED and will be migrated to new step in one of the next major plugin releases. Please refer to new universal step.
Are they saying they removed functionality and I need to either downgrade or wait for them to restore it when they get around to releasing an update?
Alternatively, if they want me to start using this new "universal step", where can I find the documentation on setting that up?
I looked at Show current state of Jenkins build on GitHub repo but it appears the answers to that question are now obsolete (answered six months ago).
I am currently using Jenkins version 2.3, Github plugin 1.19.1 and Github API plugin 1.75.
I think you may have been bitten by this issue: https://wiki.jenkins-ci.org/display/JENKINS/Plugins+affected+by+fix+for+SECURITY-170
It says
If using the standard ${sha1} branch spec, builds will fail with "Couldn't find any revision to build".
Pull requests remain in the "pending" state as the plugin fails to update the PR with the build outcome
It sounds like this can be fixed by using a whitelist of terms. In my case, this was handled by another engineer, so I can't provide firsthand details.