Jenkins is a popular open-source framework. It helps developers to automate the software development, testing, and deployment their software products, for an example Embedded Linux Yocto development.
Installing Jenkins
In prior installing Jenkins, install Java because it Jenkins requires Java.
Refer to here for installing Jenkins on Ubuntu host. Choose the LTS release instead of weekly release in order setup more stable environment.
Start Jenkins
Enable the Jenkins service to start at boot with the command
1 | sudo systemctl enable jenkins |
Check the status of the Jenkins service using the command
1 | sudo systemctl status jenkins |
If everything has been set up correctly, you should see an output like this
1 | Loaded: loaded (/lib/systemd/system/jenkins.service; enabled; vendor preset: enabled) |
Post-installation Setup
This setup wizard takes you through a few quick “one-off” steps to unlock Jenkins, customize it with plugins and create the first administrator user through which you can continue accessing Jenkins.
Refer to here to get more detailed information.
Start a New Job
- Dashboard -> click New Item ->
- Name your job item and choose the job type.
- For beginner it’s recommended to go with Freestyle project. It offers you the shell environment to design the job workflow.
- Advanced users go with Pipeline. It offers you to write down your workflow in groovy format. Hence, you will get more control.
Defining Pipeline Using Groovy Script
Dashboard -> Job Name -> Configuration ->
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61pipeline {
agent any
environment {
YOCTO_DIR = "/media/raman/development/jenkins_x86_yocto"
POKY_REPO = "git://git.yoctoproject.org/poky"
POKY_BRANCH = "kirkstone"
}
stages {
stage('Checkout Yocto') {
steps {
sh """
mkdir -p $YOCTO_DIR
cd $YOCTO_DIR
if [ ! -d poky ]; then
git clone -b $POKY_BRANCH $POKY_REPO
fi
"""
}
}
stage('Setup Build Environment') {
steps {
sh """
cd $YOCTO_DIR/poky
bash -c 'source oe-init-build-env build && sed -i "s/^MACHINE ?=.*/MACHINE ??= \\"qemux86-64\\"/" conf/local.conf'
"""
}
}
stage('Build') {
steps {
sh """
cd $YOCTO_DIR/poky
bash -c 'source oe-init-build-env build && bitbake core-image-minimal'
"""
}
}
stage('Archive Artifacts') {
steps {
sh """
mkdir -p artifacts
cp -r $YOCTO_DIR/poky/build/tmp/deploy/images/qemux86-64 ./artifacts/
"""
archiveArtifacts artifacts: "artifacts/qemux86-64/**/*", fingerprint: true
}
}
}
post {
failure {
echo 'Build failed!'
}
success {
echo 'Build completed successfully!'
}
}
}
Start the First Build of Your Job
- Dashboard -> Job Name -> click Build Now.
- Dashboard -> Job Name -> click build number(#1) -> Console Output(you can monitor/see the build status).
Make Your Jenkins Accessible Over The Network
Open the Jenkins default config file.
1 | sudo nano /etc/default/jenkins |
Make sure HTTP HOST is set to HTTP_HOST=0.0.0.0
Tell Jenkins to listen on all network interfaces.
1 | JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT" |
Save and close the config file.
Restart Jenkins.
1 | sudo systemctl restart jenkins |
Allow firewall access.
1 | sudo ufw allow 8080 |
Get the system IP.
1 | hostname -I |
You should now be able to access your Jenkins from other machines using your server’s IP address.
1 | http://172.30.70.51:8080/ |