Github jenkins webhook integration failed - jenkins

I am trying to configure webhooks in github so that it will build every time I do a new push, I have added web hooks in github and given the address of jenkins which is http://localhost:8080/github-webhook/ but it did not work and I found out that we need to find our IP address and I added it as follows: http://"my IPV4":8080/github-webhook/ and it still didn't work. I have even tried using ngrok to port forward, but it didn't work as well. It constantly throws the We couldn’t deliver this payload: Failure when receiving data from the peer error.

You need a public IP address for Github to point to detect a push request. localhost is on your local machine. You can configure jenkins on EC2 if you want to set it up for some testing.
You can use a proxy agent Ngrok.
Command :
ngrok http 8080
It will generate http://{some-number}.ngrok.io, copy the generated public address and put in your github repository webhook http://{some-number}.ngrok.io/github-webhook
At this point when you save it, it will send a post request to ngrok server, got redirected to localhost and you will see a green tick.
You can refer to this document for configuring the whole process.

Related

github webhook fails to connect to jenkins with public ip

I am trying to configure github webhooks with my jenkins server but I keep getting "failed to connect". Note that I am using a public ip and not a private or localhost address, At first, icmp protocol was blocked on my firewall but even after allowing it, it still doesn't work.
However, when I proxy my server (using smee client) and use the proxied url in the webhook instead, it works fine, so I thought the problem was jenkins url (in system configuration of jenkins) so I changed that to the public ip but it doesn't have any effect, now I'm clueless.
It might be relevant to mention that jenkins is running on a docker container,
Apparently the webhook must pass through a web server and not to jenkins directly, So I configured nginx as a reverse proxy to jenkins server and it worked fine.

How to fix "We couldn’t deliver this payload: Couldn't connect to server" in github webhook while setting up a jenkins trigger?

I'm setting up a Web-hook in GitHub to trigger a Jenkins build for every push event. I'm running Jenkins from a Blue Ocean Docker container.
https://imgur.com/bNf5dMd
I'm able to access jenkins from http://192.168.99.101:32771/ , as specified in the docker container.
I have specified the git repository and checked "GitHub hook trigger for GITScm polling" checkbox.
I am able to manually kick off the build process after a commit, but when I setup the webhook in github with the payload url http://192.168.99.101:32771/github-webhook/ and commit something,
I get the error "We couldn’t deliver this payload: Couldn't connect to server"
Other solutions I've looked at.
Using ngrok. But I'm not running this on localhost.
I tried using a Personal Access Token and created an automatic webhook from Jenkins to Github. And I got the same error.
What am I missing, or what am I doing wrong?
Github will never reach to your Jenkins Server as your server is only accessible with-in network.
The error is very clear.
We couldn’t deliver this payload: Couldn't connect to server
http://192.168.99.101:32771 this is the same as your local host in term of access it from outside of the network.
Possible solution.
Run jenkins on some remote server with Internet access and give that IP in the webhook of the Github
Pass your public IP to Github, maybe you still issue with define port forwarding if there is any issue with access.
For anyone who's jenkins server is in a Ec2 instance of AWS and if it is in a private subnet, you can do two things:
Move your private ec2 into a public subnent
Create a Load balancer (ALB) within a public subnet and attach your private ec2 instance to that Load Balancer. Then use the address of ALB for you github hook.

I can not create a Webhooks in gitlab to integrate jenkins

Prepare the environment in jenkins to integrate sonarqube and gitlab, with sonarqube I have no problem but when I try to create Webhooks, it does not let me enter a URL localhost.
If someone can help me to give access to my URL.
This was reported in gitlab-ce issue 49315, and linked to the documentation "Webhooks and insecure internal web services"
Because Webhook requests are made by the GitLab server itself, these have complete access to everything running on the server (http://localhost:123) or within the server’s local network (http://192.168.1.12:345), even if these services are otherwise protected and inaccessible from the outside world.
If a web service does not require authentication, Webhooks can be used to trigger destructive commands by getting the GitLab server to make POST requests to endpoints like http://localhost:123/some-resource/delete.
To prevent this type of exploitation from happening, starting with GitLab 10.6, all Webhook requests to the current GitLab instance server address and/or in a private network will be forbidden by default.
That means that all requests made to 127.0.0.1, ::1 and 0.0.0.0, as well as IPv4 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 and IPv6 site-local (ffc0::/10) addresses won’t be allowed.
If you really needs this:
This behavior can be overridden by enabling the option “Allow requests to the local network from hooks and services” in the “Outbound requests” section inside the Admin area under Settings (/admin/application_settings/network):

Cannot access Jenkins Master URL on slave machine

I'm trying to configure the Jenkins Master/Slave on our AWS windows server. I looked at other posts and researched online and followed the steps. I installed Jenkins on the server, and changed the jenkins url to the ip address of the server by command ipconfig: http://x.x.x.x:8080/. On the Jenkins xml file, I added the line to the argument: --httpListenAddress=0.0.0.0.
I followed the online tutorial step by step guide to set up master and agent. On the agent computer, when i try to access the url, it shows This site can’t be reached. I added the port 8080 to the firewall. I also tried to ping from the agent to the master and it failed, said lost 4 100%. I am not sure how can I access jenkins master url outside of the server. Any help is appreciated.
The root cause is hidden in the comments, so for clarity posting it as an answer - looks like the problem was that the agent is running on a users laptop and it's trying to connect on a private IP of the jenkins server running in AWS. Things should hopefully work after connecting the agent on a public IP of the master instead.

Webhook execution failed: execution expired

I am trying to trigger jenkins build whenever there is a push to GitLab.
I am referring to https://github.com/jenkinsci/gitlab-plugin.
When I test the connection for webhook it shows execution expired.
I am using:
Jenkins ver. 2.60.1
GitLab version 9.4.0-rc2-ee
Git lab plugin 1.4.6
The exact error message, clicking "Test setting" from GitLab:
We tried to send a request to the provided URL but an error occurred: execution expired
As mentioned in issue 128:
This looks and sounds like a configuration or network error.
Maybe your machine is not publicly available on the webhook address (firewall etc).
For instance, on Digital Ocean server, you would need to open up the port (mentioned in git-auto-deploy.conf.json) in the firewall:
sudo ufw allow 8866/tcp
Double-check though what you put in Manage Jenkins > Configure in term of Gitlab information (connection name, host url, credentials), as mentioned in jenkinsci/gitlab-plugin issue 391.
See GitLab Integration Jenkins: Configure the Jenkins server
It means issues in between jenkins server and gitlab or github server.
Like what I did:
I have set my local-IP:port/project/jenkins_project_name
http://192.168.1.21:8080/project/jenkins_project_name
and set the above URL in the gitlab webhook, it shouldn't work - right?
Because it's an IP that's private and not routable.
SO later I realized and set the public-IP and then hook worked.
http://public_IP:8080/project/jenkins_project_name
Note: To routable public-IP, you should expose port in your router [e.g. 8080 was for me or anything want ]
Hope this works.
I have faced the same issue.
In my case Jenkins is running in an AWS EC2 instance. I have resolved the issue by whitelisting the Public IP addresses of Gitlab on port 443 into the instance security group.

Resources