# Automate with Jenkinsfile

Automate with Jenkinsfile
=========================

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](/docs/cloudbees-ci/latest/pipelines/selecting-agents-for-your-pipelines).

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](#_footnotedef_1 "View footnote.")\], provides a number of immediate benefits:

*   Code review/iteration on the Pipeline
    
*   Audit trail for the Pipeline
    
*   Single source of truth \[[2](#_footnotedef_2 "View footnote.")\] 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.

![New Pipeline creation](_images/cjt-new-item.91bd7b2.png)

Figure 1. Create a new Pipeline

* * *

[1](#_footnoteref_1). scm, [https://en.wikipedia.org/wiki/Source\_control\_management](https://en.wikipedia.org/wiki/Source_control_management)

[2](#_footnoteref_2). [https://en.wikipedia.org/wiki/Single\_Source\_of\_Truth](https://en.wikipedia.org/wiki/Single_Source_of_Truth)