Webhook for local Jenkins and hosted Gitlab? - jenkins

I want to make a webhook for when I push something to Git lab. Git lab is hosted by school and I've installed Jenkins locally. Now when I want to make a webhook http://localhost:8080/project/timely-frontend
Gitlabs says: "URL is blocked: Requests to localhost are not allowed". Are there any other possible ways to make a push webhook?

If Jenkins and Gitlab are both installed on the same internal (school) network, try using the internal private IP address of Jenkins as the webhook URL instead of localhost.
On the Jenkins host, this can be obtained using a command line ip addr show on Ubuntu and put that in the Gitlab webhook.
Keep in mind that especially if Jenkins is running on a non-standard port (8080), other firewalls outside your control could still block the connection.

Related

How to set up an Azure DevOps service connection or endpoint to my localhost Jenkins install

I have Jenkins installed on an Ubuntu 18.04.3 LTS desktop PC on my localhost.
I also have an AzureDevOps repo on which I can successfully run a build, through a Jenkins pipeline job, connecitivity achieved via my AzureDevOps personal access token (PAT).
I am now trying to set up a Jenkins service connection or endpoint in AzureDevOps, to enable me trigger an Azure DevOps pipeline release whenever a Jenkins build completes successfully.
To achieve this in AzureDevOps, I am trying to set up access to Jenkins via a Jenkins service endpoint. The endpoint configuration requires among others, a Jenkins "Server URL" (screenshot below). Not surprisingly, AzureDevOps is unable to connect to my Jenkins instance as it's running on my local machine and therefore not publicly accessible.
Any suggestions on how I can overcome this hurdle would be most appreciated.
How to set up an Azure DevOps service connection or endpoint to my localhost Jenkins install
As we know, in order to receive the service hook notifications, you'll need to expose a port to the public internet.
To expose a port to the public internet, you can try to use the tool ngrok:
ngrok exposes local servers behind NATs and firewalls to the public
internet over secure tunnels.
Please check the document Configure a service hook for PR events for some more details.
Hope this helps.

Local Jenkins on windows connecting to remote GitLab

I want to create a webhook in remote gitlab via local jenkins installation. I managed to connect them and manually build project in gitlab after commits. But I want to do this automatically by webhook.
I got an error "Url is blocked: Requests to the local network are not allowed"
because I 'm setting webhook url in gitlab as http://172.25.203.193:9090/project/testJenkins_Angular. How could I skip this error? 172.25.203.193:9090 is Jenkin's domain. thanks
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)
Please follow this for more information.

How can I access my Jenkins dashboard on my remote droplet server?

I'm little confused about Jenkins and was hoping someone could clarify some matter for me.
After reading up on Jenkins, both from official docs and various tutorials I get this:
If I wanna set up auto deplyoment or anything Jenkins related, I could just install docker jenkins image, launch it and access it via localhost. That is clear to me.
Then, I just put Jenkinsfile into my repository, so that it knows what and how to build my repo and stuff.
The questions that I have are:
It seems to me that Jenkins needs to be running all the time, so that it can watch for all the repo changes and trigger code building, testing and deploying. If that is the case, I'd have to install Jenkins on my droplet server. But how do I then access my dashboard, if all I have is ssh access?
If Jenkins doesn't need to be up and running 24/7, then how does it watch for any changes?
I'll try to deploy my backend and front apps on docker-compose file on my server. I'm not sure where does Jenkins integrates in all that.
How Jenkins can watch for all the repository changes and trigger code building, testing and deploying?
If Jenkins doesn't need to be up and running 24/7, then how does it watch for any changes?
Jenkins and other automation servers offer two options to watch source code changes:
Poll SCM: Download and compare source code at predefined intervals.This is simple but, hardware consumption is elevated and is a little outdated
Webhooks: Optimal functionality offered by github, bitbucket, gitlab, etc. in which Github, for example, at any git event, makes an http request to your automation server, sending all the information like branch name, commit author, etc). Here more info about webhooks and jenkins.
If you don't want a 24/7 dedicated server, you can use:
Some serverless platform or just a simple application able to receive http posts + webhook strategy. For instance, Github will perform a post requet to your app/servlerless and at this point, just execute your build, test or any other commands to deploy your application.
https://buddy.works/. It is like a mini-jenkins.
If I'd have to install Jenkins on my droplet server. But how do I then access my dashboard, if all I have is ssh access?
Yes. Jenkins is an automation server, so it needs its own dedicated server.
You can install jenkins manually or use docker in your droplet. Configure 8080 port for your jenkins. If everyting is ok, just access to your droplet public ip offered by digitalocean, like: http://197.154.458.456:8080. This url must load the Jenkins dashboard.

Connection issue with Jenkins within Docker on RaspberryPi 3 (rpi-jenkins) when cloning a Bitbucket Git Repo

I'm currently playing around with Jenkins on Raspi within Docker (using dilgerm/rpi-jenkins image).
Now I have a problem with connecting to a Bitbucket Git repository.
When entering the repository url, I get (the commonly known) "Failed to connect to repository"
When using https and providing credentials (via Jenkins Credentials store), I get the error.
When using ssh and configuring the keys properly, I get the same error.
Now I am wondering if I have to configure the ssh-key withing the docker container (for the Jenkins user?). Currently, I have implemented the key on the hosting Raspi itself.
Or may it be required to configure/publish the ssl port of the Docker container on startup (-p parameter)?
Any help appreciated.

Is there any way to integrate Bitbucket on cloud and Jenkins On premise

I am trying to integrate Bitbucket on cloud and Jenkins on premise, but once I enter the IP of my local Jenkins in Bitbucket cloud it show error URL not valid.
Is there a way to solve this, or do I need to buy Jenkins cloud license?
Your local Jenkins server is not seen by a cloud Bitbucket server because it is an internal server.
You can solve it in one of those alternatives:
Ask your system administrator to expose your Jenkins server with a global IP address along with the Jenkins port (e.g. 8080) so the Bitbucket server will be able to access it. This is not totally secure due.
Activate the Jenkins job that pulls from the remote BitBucket server on time internal - in the Job 'Build Triggers' section check the 'Poll SCM' checkbox and set the cron setting (for example: 'H/15 * * * *' for building every 15 minutes. Notice that it will not build if there were no code changes)

Resources