All the following Pipeline examples assume that an agent with the required tools to complete the build has been selected. If you plan to test builds using ephemeral agents (Kubernetes-based or Docker agents), review Selecting agents. |
This guide introduces more useful steps, common patterns, and demonstrates some
non-trivial Jenkinsfile
examples.
Creating a Jenkinsfile
, which is checked into source control [1], provides a number of immediate benefits:
-
Code review/iteration on the Pipeline
-
Audit trail for the Pipeline
-
Single source of truth [2] for the Pipeline, which can be viewed and edited by multiple members of the project.
Pipeline supports two syntaxes, Declarative (introduced in
Pipeline 2.5) and Scripted Pipeline. Both of which support building continuous
delivery pipelines. Both may be used to define a Pipeline in either the web UI
or with a Jenkinsfile
, though it’s generally considered a best practice to
create a Jenkinsfile
and check the file into the source control repository.