Since Jenkins 2.0 8,793 (April 2016) the recommended job type is Pipeline: the build is a program, not a form. The freestyle job as a Declarative Pipeline:
pipeline {
agent { label 'linux' }
triggers { pollSCM('H/15 * * * *') }
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/binarybehemoth/booknest-jenkins.git', branch: 'main'
}
}
stage('Package') {
steps {
sh '''echo "Books in the seed data: $(grep -c '"title"' db/seed.json)"
tar czf booknest-$BUILD_NUMBER.tgz app.js server.js package*.json db public'''
archiveArtifacts artifacts: 'booknest-*.tgz', fingerprint: true
}
}
}
}Output
Running on agent-1 in /home/jenkins/agent/workspace/booknest-pipeline ... Books in the seed data: 6 [Pipeline] archiveArtifacts ... Finished: SUCCESS
Every field of the form became a line of code, and each stage gets its own timing and log in the Pipeline graph (Stage View). Jenkinsfiles in Source Control moves the script from the job into a Jenkinsfile in the repository. The other job types build on it: a Multibranch Pipeline runs one Pipeline per branch and pull request, an Organization Folder one Multibranch Pipeline per repository, and the old Multi-configuration project survives as the matrix directive (The matrix Directive).