Modern software is incredibly complex. That makes operations a hard job.
Architectures like microservices, increases the operational complexity multiple orders of magnitude. So, its crucial that every part of operations is automated. Because when adopting such patterns there is an explosion in the number of components that need to be maintained. Doing this manually is inefficient as well as painful for the engineers who are tasked to do the maintenance. One such area is managing your CI ojbects.
Jenkins CLI for CI
Continous integration is an essential part of modern software development and the open source tool Jenkins is a favourite when it comes to CI tools.
In general most of the work in Jenkins is done on the UI. And you will be doing similar things a zillion times with slight variations; for example, configuring a pipeline for projects that are using the same tech-stack. Why not automate this as well?
The Jenkins creators thoughtfully has provided us with a command line interface - the jenkins-cli.jar.
You can download it from your Jenkins server! Just hit JENKINS_URL/jnlpJars/jenkins-cli.jar.
Syntax and usage
The real benefit of having an API/CLI for your tools is when you automate your repetitive tasks.
If you find yourself repeating the same task, say creating similar pipelines, you can use some kind of templating to automate it.
One possible approach could be, get the XML config of
the existing job, create a template out of it by identifying the varying parts of the configuration.
envsubst to generate configs for new jobs and fire up a create job command.
CLI for jenkins lets you do most of the things you can do with Jenkins. For additional info please refer official documentation for managing jenkins with cli.