GitHub hook trigger for GITScm polling - jenkins

I configured hooktrigger job with set of pre-defined steps
1.Installed Git and Git hub
2.Jenkins URL http://localhost:8080/jenkins (Running inside Apache)
3.Mentioned Git path in configure section C:\Program Files (x86)\Git\cmd\git.exe
4.Added GitHub URL https://github.com/sanveen/HelloWorldJSP.git with Git hub credentials in job configuration
5.In github added http://localhost:8080/jenkins/hooktrigger/ as jenkins hooks URL
when i commit and pushed the code to repository, nothing happened. Seeing msg in Github as "Last delivery was not successful. Could not connect to server.
Please help to resolve on this

Related

Jenkins Build Trigger after each commit to Github

I want to set in Jenkins jobs triggering Build after each commit
I dont have access to Setting in my repository on Github, so I don't have possibility using WebHook.
What is the best/.easy way to set this in other way?
I have jobs for private repository Github, and clone project by SSH
I also using Github Oauth Token
Jenkins Continuous Integration Server is on running on a Ubuntu host
You can use local git hook pre-push. It runs after you issue the "git push" command. (but executes before pushing)
See example: pre-push hook

Apache Nifi-registry BitBucket repository?

I am looking for version control repository in BitBucket like GitHub. I have found Nifi Git repository. But at my organization we have private account in BitBucket. My question is can I create version control repository with Apache Nifi-registry in bitbucket? There is a class (org.apache.nifi.registry.provider.flow.git.GitFlowPersistenceProvider) which is associated with Git in the providers.xml file in nifi-registry. For bitbucket which class should i use? any help, guidelines will be greatly appreciated. Thanks!
It shouldn't matter where the remote git repo is located, so it should work with BitBucket just like it does with GitHub. You would clone the repo from BitBucket to the server where NiFi Registry is running, and then configure providers.xml to use the local cloned repo, and enter credentials to enable pushing to remote.
It should work the same as how you would interact with the git repo from the command line. You add or modify files in the local repo, commit them, then push to remote. In this case, all these steps will be done by registry for you.

Bitbucket webhook to trigger Jenkins job

I'm having trouble getting my webhook in bitbucket server to start a Jenkins job. I've read through the other answered questions on here and can't get it going.
Bitbucket setup:
No special plugins installed
In repository settings I have a webhook set up
URL: http://[my jenkins url]/bitbucket-hook/ (yes I have the trailing slash)
Repo Push event selected
Jenkins setup:
Bitbucket plugin installed
Created new job
Set SCM to Git and added repo details
Set branches to build to either ** or refs/heads/rob-jenkins (a branch in git)
Build when a change is pushed to bitbucket selected
What I do:
I make a change to a file in rob-jenkins branch, push and the job is not started in Jenkins.
What I see:
In bitbucket, repo settings, webhooks I can see the webhook fired as soon as the commit is pushed. It has a 200 http status code, response body is empty.
In Jenkins I've set up a logger for
com.cloudbees.jenkins.plugins.BitbucketHookReceiver
com.cloudbees.jenkins.plugins.BitbucketJobProbe
com.cloudbees.jenkins.plugins.BitbucketPayloadProcessor
com.cloudbees.jenkins.plugins.BitBucketTrigger
And when I look at those logs I can see only 1 entry from com.cloudbees.jenkins.plugins.BitbucketHookReceiver
Received commit hook notification : {"eventKey":"repo:refs_changed","date":"2018-05-22T12:18:11+1000","actor":{"name":"xxxxxx","emailAddress":"xxxxxx#xxxxxx.com","id":53,"displayName":"xxxxxx","active":true,"slug":"xxxxxxx","type":"NORMAL"},"repository":{"slug":"xxxxx","id":1,"name":"xxxxx","scmId":"git","state":"AVAILABLE","statusMessage":"Available","forkable":true,"project":{"key":"SS","id":2,"name":"xxxxx","description":"xxxxxx","public":false,"type":"NORMAL"},"public":false},"changes":[{"ref":{"id":"refs/heads/rob-jenkins","displayId":"rob-jenkins","type":"BRANCH"},"refId":"refs/heads/rob-jenkins","fromHash":"1d9ad42fa404c893853094b0072e5b839f787589","toHash":"9bf7dc873f355259e4338ee80afbd246ecbb48a9","type":"UPDATE"}]}
There are no other entries in the log.
In the job itself, the BitBucket Hook Log screen just says "Polling has not run yet."
No idea why it isn't triggering the Jenkins job... what am I missing?
I've tried setting the Poll SCM manually and that didn't make a difference.
I've done a manual build and it works fine
as commented by #tomas-bjerre the resolution was to use a different plugin
I would recommend using thie plugin instead: github.com/jenkinsci/generic-webhook-trigger-plugin – Tomas Bjerre yesterday
No plugin needed. Just add a post-recieve hook under your repo in Bitbucket. On Jenkins, under Build Triggers, Trigger builds remotely (e.g., from scripts) Trigger builds remotely (e.g., from scripts) and specify an Authentication Token. A bash or python script can be used for the hook. Anytime a git push is run (not just a commit), you trigger a build!

Triggering Multi Branch Pipeline Jenkins job using the git webhook not working

I have a multi branch pipeline job that is configured like this:
Polling is also configured for it:
When new commits are pushed to its configured Git repo, after polling, the Job is triggered as expected. In the console output the Git repo is logged as https://stash.example.com/scm/eg/project.git.
However when I try to trigger the job using the git notifyCommit webhook, I get this error message:
$ curl 'http://jenkins.example.com/git/notifyCommit?url=https://stash.example.com/scm/eg/project.git'
No git jobs using repository: https://stash.example.com/scm/eg/project.git and branches:
No Git consumers using SCM API plugin for: https://stash.example.com/scm/eg/project.git
What is missing here? Why Jenkins cannot find any jobs/git consumers for this repo to trigger it?
The reason you are getting that error is that you are using BitBucket Plugin in your job configuration so you can't you get notify endpoint to trigger builds using curl request. Also, GitNotify endpoint is part of Github plugin which scans all the job configuration which has used GitPlugin and then it cross-matched the URL of the curl request with the URL od repo used in git plugin. So, If you want to use bitbucket then follow the Instruction Documented on https://mohamicorp.atlassian.net/wiki/spaces/DOC/pages/381419546/Configuring+Webhook+To+Jenkins+for+Bitbucket+Bitbucket+Branch+Source+Plugin

Git plugin for Jenkins doesn't work with BitBucket repository

I have a project on bitbucket with git repository.
I want Jenkins job that pulls stuff from that repository. So I installed the Git Plugin.
I configure My Jenkins job to use git repository. I add credentials I use on BitBucket. Then I enter repository URL like this:
https://PawelRoman#bitbucket.org/PawelRoman/myproject.git
I'm getting the following error in red:
Failed to connect to repository : Failed to connect to https://PawelRoman#bitbucket.org/PawelRoman/myproject.git using credentials PawelRoman on BitBucket (status = 401)
401 seems like an authorization issue, but what can possibly be wrong? When I run git clone command manually from the server where I have Jenkins installed, using exactly the same repo URL and exactly the same credentials - it works without any issue. I am 100% sure the credentials are OK and repository URL is fine. How can I track down the cause of the issue?
Found out what the issue was. Repository URL was incorrect. For some reason jenkins git plugin does not allow for Username# in the repository URL.
So instead of https://PawelRoman#bitbucket.org/PawelRoman/myproject.git
You need to use
https://bitbucket.org/PawelRoman/myproject.git
And it will work.
User this url to get the project from the bitbucket
https://<user>:<pass>#bitbucket.org/<user>/<project>.git

Resources