Jenkins
Video Tutorial: Semaphore vs Jenkins
This page explains the core concepts and feature mapping you need to migrate from Jenkins to Semaphore.
Overview
The main difference between Jenkins and Semaphore is that Semaphore is a managed service while Jenkins is purely self-hosted.
In Jenkins you are in charge of configuring everything, installing plugins for all the functionality you need, managing the agents to run the workflows, creating the connections to the Git providers, managing the Jenkins instance, and the list goes on.
Semaphore is always ready to use, once you create an account and connect your Git provider you're ready to go. There is nothing to manage and you get first-class support.
Jenkins vs Semaphore
This section describes how to implement common Jenkins functionalities in Semaphore.
Checkout
Checkout clones the repository in the CI system. This is usually near the beginning of every job and workflow.
- Jenkins
- Semaphore
In Jenkins, we use the Git plugin to connect and retrieve the repository history. You need to add authentication credentials on the Jenkins instance and use them in the stage.
stage('Checkout repository') {
steps {
git branch: 'main',
credentialsId: '<my-repo-auth>',
url: 'git@github.com:<owner>/<project-name>.git'
sh "cat README.md"
}
}
When we create a project in Semaphore, the Git repository is automatically linked to the project. To clone the repository we only need to execute checkout
near the beginning of the job.
checkout
# now the code is the current working directory
cat README.md
Artifacts
Artifacts are used to store deliverables and persist files between runs.
- Jenkins
- Semaphore
In Jenkins we use archiveArtifacts
to store files:
stage('Build') {
steps {
// Your build steps here
// ...
archiveArtifacts artifacts: 'build/output/**/*.jar', fingerprint: true
}
}
And copyArtifacts
to retrieve them:
stage('Deploy') {
steps {
copyArtifacts(projectName: 'MyProject', filter: '**/*.jar', target: 'deploy-directory')
}
}
Semaphore provides an integrated artifact store that can be accessed with the artifact
tool inside any job.
To store a file we use:
artifact push workflow build
We can restore the folder with:
artifact pull workflow build
Caching
The cache speeds up workflows by keeping a copy of dependencies in storage.
- Jenkins
- Semaphore
In Jenkins, we need to install the jobcacher plugin to enable the cache. Then, we a cache stage to the workflow before building the project.
stage('Cache Dependencies') {
steps {
cache(maxCacheSize: 250, caches: [
[$class: 'ArbitraryFileCache',
includes: ['**/node_modules/**'],
excludes: [],
path: 'node_modules',
fingerprintingStrategy: [$class: 'DefaultFingerprintStrategy']]
]) {
// Your build steps go here
sh 'npm install'
}
}
}
Semaphore provides an integrated cache that can be accessed with the cache cache tool.
checkout
cache restore
npm install
cache store