The following Pipeline project types are available:
Declarative Pipeline
A declarative Pipeline provides a structured hierarchical syntax to simplify the creation of Pipelines and the associated Jenkinsfiles. It is newer than scripted Pipeline. In its simplest form, a Pipeline runs on an agent and contains stages, while each stage contains steps that define specific actions. Here is an example:
pipeline { agent { (1) label '' } stages { stage(‘Build’) { (2) steps { (3) sh ‘mvn install’ } } } }
1 | agent - An agent section specifies where tasks in a Pipeline run. An agent must be defined at the top level inside the pipeline block to define the default agent for all stages in the Pipeline. An agent section may optionally be specified at the stage level, overriding the default for this stage and any child stages. In this example, the agent is specified with an empty label filter, meaning this Pipeline will run on any available agent.
The code snippet above does not show an agent running on Kubernetes. An agent running on Kubernetes is configured differently. |
2 | stages - A stage represents a logical grouping of tasks in the Pipeline. Each stage may contain a steps section with steps to be executed, or stages to be executed sequentially, in parallel, or expanded into a parallel matrix.
It contains commands that run processes like Build, Deploy, or Tests. These commands are included in the It is advisible to have descriptive names for a There can be one or more |
3 | steps - The `steps`section contains a set of commands. Each command performs a specific action and is executed one-by-one.
|
For more information on Declarative Pipelines, see Using Declarative Pipeline syntax.
Scripted Pipeline
Scripted Pipeline is a Domain Specific Language (DSL) based on Apache Groovy. Most functionality provided by the Groovy language is made available in Scripted Pipelines. This means Scripted Pipelines can offer flexibility and extensibility to users.
However, the learning curve associated with Scripted Pipelines is very steep and it is possible to do things inside Pipelines that are better done in other tools called as part of Pipelines. CloudBees recommends the use of Declarative Pipelines rather than Scripted Pipelines.
For more information on Scripted Pipelines, see Using Scripted Pipeline syntax.
Freestyle projects
Freestyle projects are used to implement, develop, or run simple jobs. They can span multiple operations like building and running scripts.
CloudBees recommends the use of Pipeline projects instead of Freestyle projects. For information about converting a Freestyle project to a Declarative Pipeline please see Converting a Freestyle project to a Declarative Pipeline. |
Multibranch Pipelines
A multibranch Pipeline can be used to automatically create Pipelines based on branches and pull requests in your repository. For more information on multi-branch Pipelines, see Managing Multibranch Pipeline options in template.yaml
.
Organization folders
An organization folder allows CloudBees CI to automatically create multibranch pipelines for every repository within a GitHub organization or a Bitbucket Team. When a new repository is created, CloudBees CI detects it and creates a multibranch Pipeline. For more information on Organization folders, refer to Organization folders.