DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. DevOps and CI/CD
  4. Scripting Plugins in Jenkins Pipelines

Scripting Plugins in Jenkins Pipelines

Check out how the Snippet Generator tool can create an easier way to work with the many Jenkins plugins.

Duncan Brown user avatar by
Duncan Brown
·
May. 01, 19 · Tutorial
Like (2)
Save
Tweet
Share
10.90K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

When Jenkins first introduced Pipelines, the DevOps community recognized a major step forward in integrating with CI/CD solutions: The ability to create jobs either via the usual GUI or using a Groovy-based DSL meant DevOps shops could have greater control with their development workflows.  A "Jenkinsfile" (similar in nature to a Dockerfile) contains the script and can be treated as code, allowing it to be put into version control for obvious benefits.

Then Blue Ocean was announced as a way to visualize these pipeline jobs, proposing to make it easier still for shops to create pipelines in Jenkins, going so far as promising CD that "is no longer for the experts."

However, while this sounds nice on paper, one area that continues to lag with respect to Blue Ocean is that while various steps and stages can be selected in a visual manner, users are still left to write blocks of scripts to ultimately accomplish what the pipeline is supposed to do. And with a plethora of plugins now available to be used by Jenkins — each with its own commands and nuances — there is no nice way for Blue Ocean to "just know" how to use each plugin or how to guide users in their use.

So What Can We Do?

Fortunately, there is a way to help ease the learning curve for plugins with a handy feature in Jenkins.

Enter Jenkins' "Snippet Generator."

To access this, click on any pipeline that you have created (if you haven't, go ahead and create one; it doesn't require much information to setup).

From here, do the following:

  1. Click "Pipeline Syntax" on the left-hand side of the screen.

  2. Select which step you'd like to explore from the dropdown (these are augmented by the plugins installed, so if you're curious about a plugin, this is where it will appear).

  3. The step's arguments and options will appear. Here, you can set the values to be whatever you wish.

  4. When finished setting the options, click "Generate Pipeline Script."

  5. The corresponding pipeline script appears in the text area below the button. This script can be inserted directly into a Jenkinsfile for immediate use.

And that's it!

You will also notice when using the Snippet Generator that on the left-hand side of that screen there are additional helpful links to references and related documentation.

Conclusion

Jenkins' pipeline DSL is super handy to anyone operating in a DevOps environment.  Learning a slew of Jenkins plugins' ins and outs, however, can be tedious.  The Snippet Generator makes this task just a little easier.  Try it and see!

Pipeline (software) Jenkins (software)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What’s New in the Latest Version of Angular V15?
  • All the Cloud’s a Stage and All the WebAssembly Modules Merely Actors
  • Developer Productivity: The Secret Sauce to Building Great Dev Teams
  • LazyPredict: A Utilitarian Python Library to Shortlist the Best ML Models for a Given Use Case

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: