8 - Jenkins (Light Theme)
8 - Jenkins (Light Theme)
8 - Jenkins (Light Theme)
Demo Projects
❏ Watched video
Install Jenkins
❏ Watched video
❏ Demo executed
❏ Created a Server (Droplet) on DigitalOcean
❏ Configured Firewall Rules to open port 22 and port 8080 for our new
server
❏ Installed Docker on DigitalOcean Droplet
❏ Started Jenkins Docker container with named volume
❏ Initialized Jenkins
Useful Links:
Useful Commands:
Jenkins UI Tour
❏ Watched video
Check your progress... 2/7
❏ Watched video
❏ Demo executed
❏ Configured Plugin for Maven
❏ Installed npm and node in Jenkins container
Useful Links:
Useful Commands:
apt update
apt install curl
nodejs -v
npm -v
Useful Links:
Docker in Jenkins
❏ Watched video
❏ Demo executed - push Image to DockerHub Repository
❏ Made Docker available in Jenkins container (mount docker runtime inside
container as a volume)
❏ Fixed permissions on docker.sock
❏ Configured Job to build Docker Image
❏ Configured Job to push Image to DockerHub
❏ Prerequisite: Account on DockerHub
❏ Created a repository on DockerHub
❏ Created Credentials for DockerHub in Jenkins UI
❏ Tag Docker Image with your DockerHub repository, login and push to
repository
❏ Demo executed - push Image to Nexus Repository
❏ Configured “insecure-registries” on Droplet server (daemon.json file)
❏ Fixed permission for docker.sock again after restart of Jenkins container
❏ Created Credentials for Nexus in Jenkins UI
❏ Tag Docker Image with your Nexus host and repository, login and push to
repository
Useful Links:
● Java-maven-app: https://gitlab.com/nanuchi/java-maven-app/-/tree/jenkins-jobs
Check your progress... 4/7
Docker in Jenkins
Useful Commands:
# restart docker
systemctl restart docker
Useful Links:
● Java-maven-app: https://gitlab.com/nanuchi/java-maven-app/-/tree/jenkins-jobs
Check your progress... 5/7
Jenkinsfile Syntax
❏ Watched video
❏ Demo executed
❏ Used Post attribute
❏ Defined a Condition
❏ Used an environment variable
❏ Used Tools Attribute
❏ Used a Parameter
❏ Used an external Groovy Script
❏ Used an Input Parameter
Useful Links:
Useful Links:
Credentials in Jenkins
❏ Watched video
Useful Links:
● Java-maven-app:
https://gitlab.com/nanuchi/java-maven-app/-/tree/jenkins-shared-lib
● Jenkins-shared-library: https://gitlab.com/nanuchi/jenkins-shared-library
Check your progress... 7/7
Useful Links:
Useful Links:
● Java-maven-app:
https://gitlab.com/nanuchi/java-maven-app/-/tree/jenkins-jobs/Jenkinsfile-versi
on-increment
More Resources...
More Resources
Best practices
Pipeline Script/Jenkinsfile related best practices:
● Use Pipeline as Code: Store your Jenkinsfile in Git Repository (instead of inline
script in Jenkins). Good for history, working in a team etc.
● Call your Pipeline Script the default name: Jenkinsfile
● Non-Setup work should occur within a stage block. Makes your builds easier
to visualize, debug etc.
● Make sure to put #!/usr/bin/env groovy at the top of the file so that IDEs,
GitHub diffs, etc properly detect the language and do syntax highlighting for
you.
● Input Parameter: input shouldn’t be done within a node block. It’s
recommended to use timeout for the input step in order to avoid waiting for an
infinite amount of time, and also control structures (try/catch/finally).