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 Video Library
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
View Events Video Library
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
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

Migrate, Modernize and Build Java Web Apps on Azure: This live workshop will cover methods to enhance Java application development workflow.

Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.

Kubernetes in the Enterprise: The latest expert insights on scaling, serverless, Kubernetes-powered AI, cluster security, FinOps, and more.

E-Commerce Development Essentials: Considering starting or working on an e-commerce business? Learn how to create a backend that scales.

Related

  • Pipeline of an Alexa Skill with GitHub Actions
  • The Hitchhiker’s Guide  to  Jenkins Job Builder
  • Jenkins: Publish Maven Artifacts to Nexus OSS Using Pipelines or Maven Jobs
  • Getting Started With Jenkins: The Ultimate Guide

Trending

  • Enhancing Observability With AI/ML
  • Top 10 Software Architecture Patterns to Follow in 2024
  • A Comprehensive Guide to Cloud Monitoring Tools: Ensuring Optimal Performance and Security
  • A Comprehensive Approach to Performance Monitoring and Observability
  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. Butler CLI: Export/Import Jenkins Plugins and Jobs

Butler CLI: Export/Import Jenkins Plugins and Jobs

The Butler CLI makes it easier to import and export Jenkins jobs and plugins when migrating Jenkins jobs to a new server.

Mohamed Labouardy user avatar by
Mohamed Labouardy
·
Jan. 09, 18 · Tutorial
Like (3)
Save
Tweet
Share
23.6K Views

Join the DZone community and get the full member experience.

Join For Free

Not long ago, I had to migrate Jenkins jobs from an old server to a new one. That’s where StackOverflow came into play. Below are the highest-voted answers I found:

  • Jenkins CLI

  • Copy the jobs directory

  • Jenkins Remote API

  • Jenkins Job Import Plugin

In spite of their advantages, those solutions come with their downsides, especially if you have a large number of jobs to move or no access root to the server. But, guess what? I didn’t stop there. I have come up with a CLI to make your life easier and export/import not only Jenkins jobs, but also plugins like a boss.

To get started, find the appropriate package for your system and download it. For Linux:

wget https://s3.us-east-1.amazonaws.com/butlercli/1.0.0/linux/butler
chmod +x butler
mv butler /usr/local/bin/

Note: For Windows, make sure that the butler binary is available on the PATH. This page contains instructions for setting the PATH on Windows.

Once done, verify the installation worked, by opening a new terminal session and checking if butler is available :

butler help

1 — Plugins Management

To export Jenkins jobs, you need to provide the URL of the source Jenkinsinstance:

butler plugins export --server localhost:8080 --username admin --password admin

As shown above, butler will dump a list of plugins installed to stdout and a new file plugins.txt will be generated, with a list of installed Jenkins pluginswith name and version pairs:

Now, to import the plugins to the new Jenkins instance, use the command below with the URL of the Jenkins target instance as an argument:

butler plugins import --server localhost:8080 --username admin --password admin

Butler will install each plugin on the target Jenkins instance by issuing API calls.

2 — Jobs Management

To export Jenkins jobs, just provide the URL of the source Jenkinsserver:

butler jobs export --server localhost:8080 --username admin --password admin

A new directory jobs/ will be created with every job in Jenkins. Each job will have its own configuration file config.xml.

Now, to import the jobs to the new Jenkins instance, issue the following command:

butler jobs import --server localhost:8080 --username admin --password admin

Butler will use the configuration files created earlier to issue API calls to target Jenkins instance to create jobs.

Once you are done, check Jenkins and you should see your jobs successfully created:

Hope this helps! The CLI is still in its early stages, so you are welcome to contribute to the project on GitHub.

Command-line interface Jenkins (software) career Butler (software)

Published at DZone with permission of Mohamed Labouardy, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Pipeline of an Alexa Skill with GitHub Actions
  • The Hitchhiker’s Guide  to  Jenkins Job Builder
  • Jenkins: Publish Maven Artifacts to Nexus OSS Using Pipelines or Maven Jobs
  • Getting Started With Jenkins: The Ultimate Guide

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
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: