Jenkins nodelabel plugin where does .jpi come from? - jenkins

I am writing a puppet script that will automatically setup a jenkins instance with the nodelabel parameter plugins. It successfully downloads the .hpi but the plugin still doesn't work.
When I install it using the web UI I see that a working version has both .hpi and .jpi files. I can't find a link for a .jpi anywhere so I am guessing this is generated from the .hpi. I'd like to know if/how this is created during the automated install process so that I can mimic it in puppet.

The .jpi and .hpi files are just zip files (JPI = jenkins plug in, HPI = hudson plug in). If you put the .hpi in your plugins directory (probably /var/lib/jenkins/plugins) and restart Jenkins, it will install the plug in.
What I found was Jenkins-ci.org stores .hpi files, and installing this way will leave them as .hpi files. Installing through the gui changes them to .jpi.
You might also look at the one of the existing puppet modules for Jenkins.

Related

How to update log4j-1.2.12.jar file in jenkins

I have this log4j-1.2.12.jar file in my jenkins server
Path to it: /data/jenkins/.m2/repository/log4j/log4j/1.2.12/log4j-1.2.12.jar I got this Apache Log4j Unsupported Version Detection message from security team, how to resolve this I tried downloading the latest version but it is something like this log4j-api-2.19.0.jar
No, it's not "in Jenkins", more accurately, log4j is not a part of Jenkins. Jenkins consumes its jars from the exploded war in ${JENKINS_HOME}/war/WEB-INF/lib. It is not located there.
If a plugin consumes log4j, that would be found within the exploded plugin directory at ${JENKINS_HOME}/plugins/<plugin_name>/WEB-INF/lib. The status of log4j as it related to most plugins was tracked under JENKINS-67353.
What you are referencing is the maven local repository, .m2/repository. This structure is created when running a maven build on the controller; the dependency jars specified in (one of) your build's pom.xml.
The guidance in the comments is correct; find the appropriate pom.xml and update it, then rebuild.
You can verify these claims by deleting the entire .m2 directory (or moving / zip;delete if you are paranoid) and restarting Jenkins. You'll discover Jenkins is running fine and the directory remains empty. Run your maven jobs and it will repopulate, including log4j-1.2.12.jar, assuming it's still specified in your pom.xml. Fix your maven pom.xml, delete the directory, rerun your jobs and it should not reappear.
Perhaps you have already updated your pom.xml but never cleared out your local maven repository, then it will not repopulate (you could check the timestamp of the directory to know when it was first/last downloaded).
You can also delete referenced portions of the repository by specifying mvn dependency:purge-local-repository and adding -DreResolve=false to avoid re-resolving. Of course, if you've already updated the pom.xml, it would remain since it's not referenced in the pom.xml` (yes, it would be nice if there was an option to purge all or most of a repository or all version of a given jar, but ...).

Jenkins - Cancel Uninstall Plugin

I clicked uninstall for a plugin and now the Plugin Manager is showing me "Uninstallation pending" for that plugin, however, I have decided to keep the plugin. Since I cannot restart Jenkins and reinstall it at the moment, is there a way that I can cancel the request to uninstall this plugin?
Thanks!
Jenkins plugin's are under $JENKINS-HOME/plugins, [plugin].jpi files (similar content to war files, WEB-INF, META-INF) are located under this folder.
Jenkins extract these files into folder with the same name
$ ls $JENKINS-HOME/plugins/gradle*
gradle.jpi //installation file
gradle.jpi.pinned // flag file for pinned plugin
gradle.jpi.disabled // flag file for disabled plugin
gradle.bak // previous version jpi file
gradle: // extracted folder
help-GradleInstallation-home.html help-GradleInstallation-name.html help.html META-INF WEB-INF
if [plugin].jpi.pinned exists the plugin is pinned
if [plugin].jpi.disabled exists the plugin is disabled
when you upgrade plugin the old [plugin].jpi is renamed to [plugin].bak
the new one is [plugin].jpi this allows the rollback (downgrade) option
if [plugin].jpi is missing the plugin is pending uninstallion, on next restart Jenkins will delete all the files relevant to the plugin
So,
all you need to do is copy the [pluging].jpi* and [plugin] folder into $JENKINS-HOME/plugins/ folder and refresh the page, you will see it is not pending uninstall anymore.
*always recomanded to keep backup of $JENKINS-HOME dir

Use a plugin's fork for Jenkins

Instead of using this Jenkins plugin https://github.com/jenkinsci/quality-gates-plugin, I am trying to use a forked version of it: https://github.com/sarg/quality-gates-plugin that has some extra functionality.
I've downloaded the forked version as a .zip file. I changed the termination of the file from .zip to .hpi. Then, I added it to Jenkins's plugins directory.
This should have installed the plugin, right?
I am looking at installed plugins, but I can't find Quality Gates Plugin.
Do I need to do something else to install the plugin?
You have to build the plugin before uploading / installing the plugin in Jenkins. You do this by unzipping the downloaded zip file. Then, using your favorite terminal or command prompt that has maven on the path, you run mvn install. If successful, it will build the .hpi file for the plugin and can be found in the target folder, e.g. target/pluginname.hpi
For more info on plugin development and building plugins, look here.

Remove Jenkins Plugins via Script

Does anyone know how I can remove jenkins plugins from a script? I know there is no CLI command that exists for it. But was wondering, maybe you can just delete the plugin folder, and attempt to delete all associated data.
Reason I want this, is I want to develop a script that will run nightly. It will scan each Jenkins server, remove plugins if not found in file stored in GIT, it will add plugins if new ones are added, and upgrade or downgrade other plugins if the version doesn't match. The goal is to keep all Jenkins servers in sync as far as plugins go.
Any thoughts on how I can achieve this goal?
groovy script for removing a plugin:
String pluginNameToRemove = "myPluginToRemove"
def jenkins = Jenkins.getInstance()
def pluginManager = jenkins.getPluginManager()
def pluginWrapperToUninstall = pluginManager.getPlugin(pluginNameToRemove)
pluginWrapperToUninstall.doDoUninstall()
You can also remove the content of the plugins folder, download all the plugins you want according to the file, copy them to the plugins folder and restart jenkins. (We have a very similar flow on our environment for deploying jenkins instances)

Installing Nimble for Grails

I came across Nimble yesterday, but couldn't get past Step 1, configuring BuildConfig.groovy to find the Nimble's remote repository.
My BuildConfig.groovy file is one line:
grails.plugin.repos.discovery.intient="http://intient.com/downloads/grails/
Here is the message I get when running grails install-plugin nimble 0.2:
Welcome to Grails 1.1.1 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /opt/dev/sdks/grails-1.1.1
Base Directory: /home/wraith/dev/source/demo
Running script /opt/dev/sdks/grails-1.1.1/scripts/InstallPlugin.groovy
Environment set to development
No authentication for svn repo at intient ...
Reading remote plugin list ...
Reading remote plugin list ...
Reading remote plugin list ...
Plugin 'nimble' was not found in repository. If it is not stored in a configured repository you will need to install it manually. Type 'grails list-plugins' to find out what plugins are available.
This is the first time I have tried to install a plugin not in the official repository. What is the best way to narrow down if it is a problem at Intient.com or with my configuration?
Follow these instructions with the following modifications:
Step 1 is correct
Instead of using the remote repository, download the zipped plugin
Move the plugin to ~/dev/plugins
grails install-plugin ~/dev/plugins/grails-nimble-0.2.zip
Steps 3-5 are correct
We were performing some maintenance on intient.com and the load balancer wasn't providing this content for the last 12 hours or so (oops!).
Should be sorted now but the steps Wraith Monster gave above work for a manual install as well.
Once Grails 1.2 proper hits Nimble will be part of the official plugin repo and we won't need to worry about this at all.
you could always download the zip file for the plugin and install it manually
Download source code from http://github.com/intient/nimble
Unzip under your plugins directory of your project (usually under ${USER_HOME}/.grails/<grails-version>/projects/<myproject>/plugins)
Rename the extracted folder into "nimble-0.2"
Remove from BuildConfig the line grails.plugin.repos.discovery.intient="http://intient.com/downloads/grails/"
Edit the file application.properties of your project and add the line plugins.nimble=0.2
If not installed under your project, you should install the plugins : shiro (version 1.0-SNAPSHOT at least) and mail (>0.6). (run command grails install-plugin <pluginName> <version>)
Start directly from Step 3
It should work (at least, it worked for me). Good luck

Resources