I've a problem with jenkins docker integration - docker

I've a gitlab container and i've a jenkins container locally. I can configured the CI, but but i can't solve the cd. I would like to when i push the code to repo the jenkins build my Blazor Server App solution in docker container locally.
Can you help me ?

Setup a Gitlab webhook like so: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html
set up a Jenkins pipeline with the necessary information inside a jenkinsfile like so: https://www.jenkins.io/doc/book/pipeline/jenkinsfile/
The Gitlab webhook should send a request to the local jenkins container to execute the pipeline. You will need to make sure the appropriate ports are opened and linked between the container and the host computer.

Related

Jenkins on k8s and pipeline with docker agent

I want to run my Jenkins behind k8s. We can achieve that with any standard helm chart or our own manifest files. In this case, Jenkins (master only) will run inside a container (Pod).
Now I also want to have a pipeline job that uses docker agent as described here
I am getting confused, about
how and where this docker container will be run (on the same node where Jenkins is running? and suppose the node capacity is over then it needs to run docker agent on a different node)
how does Jenkins will authenticate to run containers on k8s nodes?
I saw the Kubernetes plugin/docker plugin. But those plugins create containers beforehand (or at least we need to set up a template, which decides how containers will start, which image will be used and many more) and connects Jenkins with help of JNLP / ssh. I lose the flexibility to have an image as an agent in that case.
going further, I also like to build custom images on the fly with help of Dockerfile shipped along with code. An example is available in the same link.
I believe this documentation is answering all of your questions: https://devopscube.com/jenkins-build-agents-kubernetes/
With this method, you are not losing your flexibility because your Jenkins master going to create a K8s pod on the fly. Yes, additionally you need JNLP authentication but you can think of that as a sidecar container.
About your first question: If you use exactly that way, your Jenkins jobs going to run under Jenkins master with the same Docker that your Jenkins Master is using.

Differences between Jenkins docker-agent and docker-inbound-agent

I couldn't get the differences or better say the benefits of using docker-agent or docker-inbound-agent for Jenkins as part of Cloud Nodes.
currently, I am using the routine Docker configuration for Configuration Cloud to use docker as agent to build application.
Jenkins Controller running on Host#1
another host for running docker agents!
base on GitHub readme:
docker-inbound-agent is using TCP or WebSockets to establish inbound connection to the Jenkins master.
docker-agent
docker-inbound-agent
According the docker-agent readme on github :
This image is used as the basis for the Docker Inbound Agent image. In
that image, the container is launched externally and attaches to
Jenkins.
This image may instead be used to launch an agent using the Launch
method of Launch agent via execution of command on the master.
docker-agent is used to launch an agent with a command on the master :
This launch the agent on the master.
docker-inbound-agent got the docker-agent image as basis (see on a Dockerfile) :
ARG version=latest-alpine-jdk11
FROM jenkins/agent:$version
This image was before named jnlp-slave (see this link) which got the same goal. This setup an agent which connect to the jenkins using the TCP protocol.
You also have a third agent, the docker-ssh-agent which is used to be connected to the master with SSH.

Gitlab webhook to Docker Container running Jenkins hosted on home network

I have an Ubuntu server running 2 docker containers one is running Jenkins and the other one is running Sonarqube. My school has a private gitlab server from this server I want to create an webhook to my Jenkins to trigger a build but the following error is coming up.. And I Don't know what is going on...
enter image description here
Both port forwarded via router using the following ports:
jenkins xx.xx.xx.xxx:8080
sonarqube xx.xx.xx.xxx:8090
Getting the following error when testing the webhook using the by jenkins provided url to trigger: http://xx.xx.xx.xxx:8080/project/some_project
enter image description here
Does it have to do with docker?

Making docker container a build executor for jenkins

I have a ec2 instance running as my jenkins master. I would like to run a container in that instance that will be used as another build executor so I can tun a few builds simultaneously.
Im having pronblems connecting these.
In the docker hub jenkins docs it says under the relevant section:
You can run builds on the master out of the box.
But if you want to attach build slave servers through JNLP (Java Web
Start): make sure you map the port: -p 50000:50000 - which will be
used when you connect a slave agent.
If you are only using SSH slaves, then you do NOT need to put that
port mapping.
but when I try to add a node in the jenkins config, it asks remote root directory (probably should be /var/jenkins ? ) and a launch method.
I don't quite understand what I should give it as its launch method to make this work and I don't understand where the port number comes into play.
What you need is Jenkins Docker plugin (link below) and follow the instructions listed here
https://wiki.jenkins.io/display/JENKINS/Docker+Plugin
I followed those instructions and was able to setup dynamic slaves in Jenkins which are dynamically provisioned.

Jenkins run job in local docker image

Hi I have a Jenkins where I want to run a job in a remote machine using a docker image that I already have on that machine since my cluster does not have any internet access.
I have seen Jenkins docker plugin, but it seems it´s using a docker repository to get the images.
My question is, which is the best Jenkins plugin to acomplish this?. Run a Jenkins job in a docker container using an image in the machine where the job is running?
Regards.

Resources