DEV Community

Carlos Saltos
Carlos Saltos

Posted on

Install Jenkins on Debian 11 Bullseye

What?

A quick tip for using Jenkins LTS 2.319.2 and up on Debian GNU/Linux 11 Bullseye (it may work for other Linux systems too like CentOS, RedHat, Fedora, ArchLinux and Gentoo).

Why?

Because you can have your own TravisCI, Vercel or Netlify and Jenkins is a good start.

How?

  • Create a file at /etc/jenkins/jenkins.conf with the content
JENKINS_WAR=/opt/jenkins/jenkins.war

JENKINS_HOME=/opt/jenkins/home

JAVA_ARGS="-Djava.awt.headless=true \
  -Djava.net.preferIPv4Stack=true \
  -XX:+AlwaysPreTouch \
  -XX:+UseG1GC \
  -Xms1024m \
  -Xmx1024m \
  -Xss16m \
  -Xlog:gc*=debug:file=gclog.log:utctime,level,tags:filecount=9,filesize=1M"

JENKINS_ARGS="--httpPort=8080 \
  --logfile=/var/log/jenkins/jenkins.log \
  --useJmx"
Enter fullscreen mode Exit fullscreen mode
  • Then a file at /lib/systemd/system/jenkins.service with the content:
[Unit]
Description=Jenkins
After=network.target

[Service]
Type=simple
User=jenkins
Group=jenkins
EnvironmentFile=/etc/jenkins/jenkins.conf
ExecStart=/usr/bin/java $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS
WorkingDirectory=/opt/jenkins/home
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
Enter fullscreen mode Exit fullscreen mode
  • Create the jenkins user with the jenkins group

  • Create the /opt/jenkins/home and /var/log/jenkins directories with jenkins user as the owner

  • Download Jenkins war from https://www.jenkins.io/download/ to /opt/jenkins/jenkins.war (it's the Generic Java Package .war link)

  • Ensure you have Java installed and start Jenkins with the command systemctl start jenkins

  • Go to http://localhost:8080/ and start building !!

Where?

Tested on Debian 11 Bullseye arm64 and OpenJDK 11 in and AWS m6g.large (it may work also locally and with amd64 chips using newer version of Java like Java 17)

Based on:
https://www.jenkins.io/doc/book/managing/system-properties/
https://www.jenkins.io/doc/book/installing/initial-settings/
https://github.com/jenkinsci/winstone#command-line-options
https://gist.github.com/karnauskas/aca138bb8338689a178e

Top comments (0)