Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature to register analytics plugin only if available #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/io/openshift/Plugins.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package io.openshift

import io.openshift.plugins.analytics
import io.openshift.Globals
import static io.openshift.Utils.pluginAvailable

class Plugins implements Serializable {
static def register() {
// analytics plugins is enabled by default
Globals.plugins["analytics"] = Globals.plugins["analytics"] ?: [disabled: false]
if (Globals.plugins["analytics"].disabled ?: false) {

def disabled = Globals.plugins["analytics"].disabled ?: false
if (disabled || !pluginAvailable("bayesian")) {
return
}
new analytics().register()
Expand Down
5 changes: 5 additions & 0 deletions src/io/openshift/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,9 @@ class Utils {
}
}

// return true if given pluginName is available in Jenkins otherwise false
static boolean pluginAvailable(pluginName) {
return jenkins.model.Jenkins.instance.getPluginManager().getPlugin(pluginName) ? true : false
}

}