Jenkins installation is quite trivial on FreeBSD. All you have to do is issue a package install command and you’re done with a new, shiny Jenkins to play with 🙂
What I will show in this tutorial is how to install it using standard FreeBSD build process. For example, the latest version of the Jenkins that you want is not yet available at the FreeBSD binary repository, then we can install it from ports tree.
I have installed the latest FreeBSD 12.1 in AWS and from connection via SSH, I will do the installation using the usual binary package install first.
$ ssh -i jenkins_keypair.pem ec2-user@x.x.x.x
Last login: Wed Oct 7 06:33:18 2020 from x.x.x.x
FreeBSD 12.1-RELEASE-p10 GENERIC
Welcome to FreeBSD!
$ su
root@freebsd:/usr/home/ec2-user # pkg install jenkins-lts
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100% 916 B 0.9kB/s 00:01
Fetching packagesite.txz: 100% 6 MiB 6.6MB/s 00:01
Processing entries: 100%
FreeBSD repository update completed. 31943 packages processed.
All repositories are up to date.
Updating database digests format: 100%
The following 1 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
jenkins: 2.235.5
Number of packages to be installed: 1
The process will require 64 MiB more space.
63 MiB to be downloaded.
Proceed with this action? [y/N]:y
As of this writing, the latest Jenkins LTS is now 2.249.1 which means that the one we have installed above (2.235.5) is behind in minor releases.
In this case, lets install it from the ports collection method.
//if you go trying cd /usr/ports and complained that it's not yet existing, then you have to do portsnap first
root@freebsd:~ # portsnap auto
root@freebsd:~ # cd /usr/ports/devel/jenkins-lts
root@freebsd:~ # make install clean
If the compilation from source finishes without error, lets add an entry –httpPort=8180 –prefix=/jenkins in /usr/local/etcs/rc.d/jenkins before starting the Jenkins service as shown below.
>root@freebsd:~ # vi /usr/local/etc/rc.d/jenkins
#!/bin/sh
# $FreeBSD: head/devel/jenkins-lts/files/jenkins.in 544212 2020-08-05 09:17:50Z lwhsu $
#--- snip ---
: ${jenkins_enable:=NO}
: ${jenkins_home="/usr/local/jenkins"}
: ${jenkins_args="--webroot=${jenkins_home}/war --httpPort=8180 --prefix=/jenkins"}
: ${jenkins_java_home="/usr/local/openjdk8"}
: ${jenkins_user="jenkins"}
: ${jenkins_group="jenkins"}
: ${jenkins_log_file="/var/log/jenkins.log"}
#--- snip ---
If you encountered error in the initial build make sure you have an updated pkg package by doing :
cd /usr/ports/ports-mgmt/pkg
make deinstall
make reinstall