Jenkins
Purpose
Jenkins is installed on the remote server (Metanet) to work as a build tool and deploy certain web applications automatically, namely:
- the entire https://develop-ing.ch suite, including the internal version of Book-a-desk
- the internal IT documentation page based on VitePress (https://docs.develop-ing.ch)
Access
The Jenkins web UI is accessible via the Jenkins subdomain https://jenkins.develop-ing.ch/, although connection is only allowed through WireGuard. Therefore, you need to make sure to add the following IP addresses to your AllowedIPs in your WireGuard configuration (additionally to the internal VPN net address).
AllowedIPs = 185.46.57.64/32, 2a00:1128:200:4:0:56ff:fee8:69a4/64Setup
About
Jenkins is set up to run in two separate Docker containers, the Jenkins master and the Jenkins agent. In order for the build processes to run properly, both have to be up because of their distinct functionalities:
- The Jenkins master works as the controller. It tells the Jenkins agent what needs to be built, how it needs to be built and when it needs to be built.
- The Jenkins agent executes the builds it was assigned by the Jenkins master.
Jenkins Master
Run the following command to set up the Jenkins master in a Docker container.
docker run -d \
--name jenkins-master \
-p 127.0.0.1:8090:8080 \
-v /var/jenkins_home:/var/jenkins_home \
-v /var/run/docker.sock:/var/run/docker.sock \
jenkins/jenkins:ltsJenkins Agent
Run the following command to set up the Jenkins agent in a Docker container.
docker run -d \
--name jenkins-agent \
--network jenkins-network \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /home/django/web-framework:/home/django/web-framework \
-v /home/django/web-framework-env:/home/django/web-framework-env \
-v /home/django/backup:/home/django/backup \
-v /var/run/postgresql:/var/run/postgresql \
-e JENKINS_URL=http://develop-ing.ch:8090/ \
-e JENKINS_AGENT_NAME=jenkins-agent \
-e JENKINS_SECRET=fedd3ace963b328ef54709235a2865b392f21710e95452efe76c1c0b43e8d8fe \
-u root \
jenkins/inbound-agent:latest &Connecting the Containers
After the Docker container for the Jenkins agent is up and running, it has to be connected to the Jenkins master container as follows:
curl -sO https://jenkins.develop-ing.ch/jnlpJars/agent.jar
java -jar agent.jar -url https://jenkins.develop-ing.ch/ -secret fedd3ace963b328ef54709235a2865b392f21710e95452efe76c1c0b43e8d8fe -name metanet -webSocket -workDir "/var/jenkins-agent" &Occasional Issues
Occasionally, the Jenkins agent will disconnect from the Jenkins master on its own, which, historically, is the primary reason why build jobs do not run properly. In that case, the connection commands above simply need to be entered again to re-establish the connection. Please note that after a reinstall of the Jenkins master, the secret in the above command would have to be replaced with a new secret. It can be accessed via the following URL.
https://jenkins.develop-ing.ch/manage/computer/metanet/In case the agent is named differently, please replace metanet with the new name in order to access the site.
