Chef Cookbooks: Installing Jenkins plugins from GItHub - jenkins

I am using Chef to deploy my Jenkins instance. I am currently using the Jenkins cookbook found in the Chef Supermarket: https://supermarket.chef.io/cookbooks/jenkins .
I'm managing my plugins by adding them to the _master_war.rb recipe file. Most plugins I'm finding are straight forward, follow the specified instructions in the cookbook supermarket page and can be found for download on the https://wiki.jenkins-ci.org site with a link to a hpi/jpi file.
I'm finding some plugins which are only available via GitHub. For example, https://plugins.jenkins.io/workflow-cps. My current plugin code looks like thus:
# Installs the latest version of the workflow-job Plugin for Jenkins
# The BitBucket Build Status Notifier plugin is dependent on this plugin
# https://github.com/jenkinsci/workflow-job-plugin
jenkins_plugin 'workflow-job-plugin' do
source 'https://github.com/jenkinsci/workflow-job-plugin.git'
notifies :restart, 'runit_service[jenkins]', :immediately
end
Unfortunately, this syntax does not appear to install the plugin via git successfully on my jenkins instance. The following warning appears after running the recipe on the node jenkins is running on:
Bitbucket Build Status Notifier Plugin v1.3.3
workflow-job v1.11 is missing. To fix, install v1.11 or later.
workflow-cps v1.11 is missing. To fix, install v1.11 or later.
multiple-scms v0.6 is missing. To fix, install v0.6 or later.
What would be the correct way / syntax to use to go about downloading and installing these plugins from github to my jenkins instance using the jenkins cookbook for Chef?

I would to to add to this discussion that I found a way to work through this issue. When a page like this one is the official source for a Jenkins plugin: plugins.jenkins.io/workflow-cps, on the right hand side of the screen is an 'Archives' link which will take you to the .hpi listing for all available versions of the given plugin. I.E. updates.jenkins.io/download/plugins/workflow-cps . Using the link address for the listed versions you can source the appropriate .hpi file

Related

Jenkins upgrade from 1.6xx to 2.xx (1.642.3 -> 2.32.2)

I upgraded Jenkins to 2.32.3 version (in place upgrade) after taking necessary backups (THIN) or $JENKINS_HOME and Jenkins is now UP and running.
Under Manage Jenkins > Manage Plugins, I see the following RED error:
Manage Jenkins
Correct
There are dependency errors loading some plugins:
Environment Injector Plugin v2.1.3
envinject-api v1.2 is missing. To fix, install v1.2 or later.
While trying to install Environment Inject Plugin 2.1.3, the logs (during download/install) shows the same error:
Installing Plugins/Upgrades
Preparation
Checking update center connectivity
Success
Environment Injector Plugin
Failure -
java.io.IOException: Failed to dynamically deploy this plugin
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1895)
at hudson.model.UpdateCenter$DownloadJob.run(UpdateCenter.java:1652)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Failed to install envinject plugin
at hudson.PluginManager.dynamicLoad(PluginManager.java:873)
at hudson.PluginManager.dynamicLoad(PluginManager.java:813)
at hudson.model.UpdateCenter$InstallationJob._run(UpdateCenter.java:1891)
... 5 more
Caused by: java.io.IOException: Environment Injector Plugin v2.1.3 failed to load.
- envinject-api v1.2 is missing. To fix, install v1.2 or later.
at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:621)
at hudson.PluginManager.dynamicLoad(PluginManager.java:863)
... 7 more
Where can I get this envinject-api 1.2 plugin? Should I go grab the Github project (clone it) and build the Maven project and put the hpi file under $JENKINS_HOME/plugins folder?
Under Available plugins tab, I don't see an option to select a given version (only 2.1.3 is available). I don't see envinject-api 1.2 plugin listed there either that I can select. My understanding it, selecting Environment Inject 2.1.3 should auto grab all of its dependent plugins for free per it's MANIFEST file.
$ cat $JENKINS_HOME/plugins/envinject/META-INF/MANIFEST.MF
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: nenashev
Build-Jdk: 1.8.0_121
Extension-Name: envinject
Specification-Title: The Jenkins Plugins Parent POM Project
Implementation-Title: envinject
Implementation-Version: 2.1.3
Plugin-Class: org.jenkinsci.plugins.envinject.EnvInjectPlugin
Group-Id: org.jenkins-ci.plugins
Short-Name: envinject
Long-Name: Environment Injector Plugin
Url: https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
Compatible-Since-Version: 2.0
Plugin-Version: 2.1.3
Hudson-Version: 1.625.3
Jenkins-Version: 1.625.3
Plugin-Dependencies: envinject-api:1.2,ivy:1.21;resolution:=optional,m
atrix-project:1.7,script-security:1.22
Plugin-Developers: Gregory Boissinot:gbois:gregory.boissinot#gmail.com
,Oleg Nenashev:oleg_nenashev:o.v.nenashev#gmail.com,Manuel Recena:rec
ena:recena#gmail.com
For some reason Jenkins plugins (didn't download the dependent plugins per the Manifest file).
As envinject-api plugin was not listed in the AVAILABLE plugin tab (under Manage Jenkins > Manage Plugins section), I had to manually download the .hpi / .jpi file directly from the following download plugins URL and then I placed the file in $JENKINS_HOME/plugins folder.
https://updates.jenkins-ci.org/download/plugins/
wget https://updates.jenkins-ci.org/download/plugins/envinject-api/1.2/envinject-api.hpi
Restarted Jenkins sudo service jenkins restart (or any other way you have setup) and this issue went away from both Jenkins GUI and from tail -f /var/log/jenkins/jenkins.log
PS: Don't just randomly select a latest version of any plugin or it's dependent plugin. It may not work and break more other plugins as it depends upon your current Jenkins version.
Found this link for Juseppe, not sure how relevant is this but seems interesting: https://github.com/yandex-qatools/juseppe

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.

Grails Plugins from GitHub

If I want to use a plugin for Grails from Git Hub. Do I just download the zip file and make it available in my local maven repository? I'm behind a firewall which doesn't let me just resolve the dependencies.
You can get the source and run maven-install to make it available in your local maven repository, then you declare the dependency in the plugins block of the BuildConfig.groovy.
You shouldn't build from the repo source since that might include unfinished features and bugs. At the very least use source tagged for a particular release (if there are any).
If you want to download released plugins, they're available at http://repo.grails.org/grails/plugins/org/grails/plugins/
Keep in mind that running grails install-plugin /path/to/zip no longer works in 2.3, so you should stay away from that approach. Instead, you could run a local Artifactory instance that acts as a cached plugin repo - see this thread for some information to get started: http://grails.1312388.n4.nabble.com/Caching-plugins-using-artifactory-td4640164.html
The zip file which will be downloaded will be the source of the plugin. You have to extract the zip, go to the root of the plugin, and run grails maven-install (from release plugin) which would build the plugin artifact for you in you local maven repository if you have one setup.
Then you can use the plugin.
OR
You can use the plugin inline as mentioned in this answer.
Proxy setting can also be configured in grails by add proxy and set proxy.
grails add-proxy myproxy "--host=myproxy" "--port=myport" "--username=proxyuser" "--password=mypassword"
grails set-proxy myproxy
see grails docs.
if above solution doesn't work try then
create ProxySettings.groovy in C:\Documents and Settings\user-name.grails folder
add following two lines to this file and save
myproxy=["http.proxyHost":"myproxy", "http.proxyPort":"4300", "http.proxyUserName":"proxyuser", "http.proxyPassword":"mypassword"]
currentProxy="myproxy"
please check this link for more options
You can also keep plugins locally as described here
http://blog.armbruster-it.de/2011/10/project-setup-for-grails-with-customized-plugins-using-git-submodules/
git submodule add git://github.com/sarmbruster/grails-spring-security-ui.git plugins/grails-spring-security-ui
git add .gitmodules plugins/
git commit -m "added submodule"
now add plugins/grails-spring-security-ui as a inline plugin by adding to grails-app/conf/BuildConfig.groovy
grails.plugin.location.'spring-security-ui'="plugins/grails-spring-security-ui"
That's all.
More info in section "Installing Local Plugins" and "Specifying Plugin Locations" in docs:
http://grails.org/doc/latest/guide/plugins.html#12.1%20Creating%20and%20Installing%20Plug-ins

Jenkins nodelabel plugin where does .jpi come from?

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.

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