I need a way to get a list of plugins so that I can use them with docker jenkins
in the format <plugin>:<version>
The jenkins CLI will allow us to interact with our jenkins server from the command line. We can get it with a simple curl call.
curl 'localhost:8080/jnlpJars/jenkins-cli.jar' > jenkins-cli.jar
We need to create a groovy script to parse the information we receive from the jenkins API. This will output each plugin with its version. Save the following as plugins.groovy.
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
plugins.each {println "${it.getShortName()}:${it.getVersion()}"}
Use jenkins-cli.jar to call the jenkins server where it is located (localhost:8080) in this case with the username and password you use for login and then output the results to plugins.txt
java -jar jenkins-cli.jar -s http://localhost:8080 -auth admin:<password> groovy = < plugins.groovy > plugins.txt
The output looks like this
trilead-api:1.0.6
gradle:1.36
cloudbees-folder:6.12
workflow-basic-steps:2.20
antisamy-markup-formatter:2.0
branch-api:2.5.6
jdk-tool:1.4
structs:1.20
handlebars:1.1.1
workflow-step-api:2.22
token-macro:2.12
Enjoy!
Remove blank between shortName and Version.
So that we can use
install-plugins.shto install plugins with plugins.txt directly.