Post

Setting up Jenkins on Synology NAS Docker

There are many CI/CD(Continuous Integration/Continuous Deployment)tools, and Jenkins is one of the useful tools that does not have license restrictions and open source. I would like to talk about how to install Jenkins on Synology NAS Docker.

  • https://pkg.jenkins.io/debian

Basic Environment

JDK version 8 or higher is required for Jenkins to operate. Install JDK version 11.

1
2
3
4
5
6
7
8
9
10
apt-get update
apt-get install -y openjdk-11-jdk

java -version
# + --------------------------------------------------------
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu120.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu120.04, mixed mode, sharing)
# - --------------------------------------------------------

Install Jenkins package

To install Jenkins using APT, server information must be added to APT. After adding Jenkins server information, an error occurs during apt update saying there is no key. Add the key to apt-key using the key displayed in the error message. In my case the key was 5BA31D57EF5975CA.

Once you have added key information to APT, install Jenkins.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list

apt-get update
# + --------------------------------------------------------
...
W: GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldnt be verified because the public key is not available: NO_PUBKEY 5BA31D57EF5975CA
E: The repository 'http://pkg.jenkins.io/debian-stable binary/ Release' is not signed.
...
# - --------------------------------------------------------

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 5BA31D57EF5975CA
# + --------------------------------------------------------
Executing: /tmp/apt-key-gpghome.d7qO7VDcMV/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 5BA31D57EF5975CA
gpg: key 5BA31D57EF5975CA: public key "Jenkins Project <jenkinsci-board@googlegroups.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
# - --------------------------------------------------------

apt-get update
# + --------------------------------------------------------
Ign:1 https://pkg.jenkins.io/debian-stable binary/ InRelease
Get:2 https://pkg.jenkins.io/debian-stable binary/ Release [2044 B]
Get:3 https://pkg.jenkins.io/debian-stable binary/ Release.gpg [833 B]
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Get:6 https://pkg.jenkins.io/debian-stable binary/ Packages [29.6 kB]
Hit:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:8 http://security.ubuntu.com/ubuntu focal-security InRelease
Fetched 32.5 kB in 2s (19.3 kB/s)
Reading package lists... Done
# - --------------------------------------------------------

apt-get install jenkins

The port number for connecting Jenkins to the web is defined in HTTP_PORT in the /etc/default/jenkins file. If you need to change the port number, you can change it from 8080 to the desired value.

1
2
3
4
5
6
7
vi /etc/default/jenkins
# + --------------------------------------------------------
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080
# - --------------------------------------------------------

Configure Synology NAS container port and run Jenkins

Afterwards, stop the Ubuntu container in the Synology NAS GUI and set the port for external connection to Jenkins. I mapped the container’s 8080 port to 48080 port.

Synology NAS GUI - Docker - Jenkins Port Settings Synology NAS GUI - Docker - Jenkins Port Settings

Start the Ubuntu container and run the Jenkins service. In short, if Ubuntu Docker is stopped and restarted, you need to run the Jenkins service again.

1
2
sleep 10
service jenkins restart

Then, connect to Jenkins using a web browser. In my case, the IP address assigned to Synology NAS was 192.168.0.50 and the port was 48080 set above.

  • http://192.168.0.50:48080/

Jenkins - Getting Started Jenkins - Getting Started

Log in with the initial password written in the /var/lib/jenkins/secrets/initialAdminPassword file and proceed with the initial Jenkins installation.

1
2
3
4
cat /var/lib/jenkins/secrets/initialAdminPassword
# + --------------------------------------------------------
72b349dadd5d4a83bac10060e536189e
# - --------------------------------------------------------

This post is licensed under CC BY 4.0 by the author.