Table Of Contents
- Jenkins Pipeline
- Need for Jenkins Pipeline as Code
- Features of Pipeline as Code
- Pipeline Autocompletion in IntelliJ
- Snippet Generator
- Jenkins Declarative Pipeline Example
Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins.
Need for Jenkins Pipeline as Code
Over time, Jenkins, like most other self-hosted CI/CD tools resulted in:
- Accumulation/tendency to create vast number of jobs
- Hard and costly maintenance
- Heavy reliance on UI
- Lack of powerful ways to specify conditional logic
Features of Pipeline as Code
Pipelines are implemented as code and typically checked into source control, serving as a single source of truth enabling the team members to edit, review, and iterate upon their pipeline.
Pipelines can optionally stop and wait for human input or approval before continuing the Pipeline run.
Pipelines support complex real-world requirements
- Conditional executions
- Chaining jobs
- Linear/Complex flows
The Pipeline plugin supports custom extensions to its DSL and multiple options for integration with other plugins.
Pipeline Autocompletion in IntelliJ
To enable code completion follow below steps:
- Download Pipeline GDSL (http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl) from your jenkins.
- Add Groovy SDK support to Intellij.
- Place the GDSL file inside
srcdirectory of your project and mark the
- Open the GDSL file. Now, IntelliJ will show a message
DSL descriptor file has been changed and isn't currently executed.. Click
- Now create your
.groovyjenkins file and write the code, auto completion will work.
You can also generate snippets of code for the pipeline steps using the
Snippet Generator feature available in Jenkins (http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/) which you can then make use of in your pipeline.
Replay feature allows you to test your pipeline code without having to commit the changes to your Repo. Once you have tested the code you can then push your changes.
Jenkins Declarative Pipeline Example