Skip to content

Commit

Permalink
Feature to register analytics plugin only if available
Browse files Browse the repository at this point in the history
This patch will add a feature to register
Analytics Plugin only if it is there in jenkins

Fixes #74
  • Loading branch information
piyush-garg committed Jan 29, 2019
1 parent 868a674 commit 18476da
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ This is the API where you provide configurations like runtime or something like

If above block is configured in your pipeline then every time the spined pod will have a container named `node` which having the environments for nodejs8. By default pod will be spined with basic utilities like `oc`, `git` etc


**Variables Configured in Pipeline**

| Name | Required | Default Value | Description |
|-----------------------|------------|-----------------|-----------------------------------------------------|
| runtime | false | none | runtime of the application ex java, node, go etc. |
| version | false | none | version of the runtime using |

### ci

This is the block which will be executed for continuous integration flow. By default all branches starting with name `PR-` will go through this execution. You can override by providing a branch name in arguments
Expand Down Expand Up @@ -252,6 +260,8 @@ as `params`.
Following template parameters must be present in the template and is set to the
following values by default. You can override them by passing key value pairs in params.

**Template Parameters**

| Name | Default Value |
|-----------------------------|------------------------------------------|
| SUFFIX_NAME | branch name |
Expand All @@ -276,8 +286,8 @@ This API can read multiple resources separated by `---` from the yaml file.

| Name | Required | Default Value | Description |
|----------------|------------|------------------------------|------------------------------------------------------------------------|
| file | true | none | An relative path of resource yaml file. |
| validate | false | true | A validation for resource yaml file. |
| file | true | none | An relative path of resource yaml file. |
| validate | false | true | A validation for resource yaml file. |

### build

Expand Down Expand Up @@ -332,8 +342,8 @@ or like
|----------------|------------|----------------|------------------------------------------------------------------------------------------------|
| resources | true | null | OpenShift resources at least deploymentConfig, service, route, tag and imageStream resource. |
| env | true | null | environment where you want to deploy - `run` or `stage` |
| approval | false | null | if provided `manual` then user will be asked whether to deploy or not |
| timeout | false | 30 | time (in minutes) to wait for user input if approval is `manual` |
| approval | false | null | if provided `manual` then user will be asked whether to deploy or not |
| timeout | false | 30 | time (in minutes) to wait for user input if approval is `manual` |

The route generated after above step will be added as annotation in the pipeline.

Expand Down
5 changes: 4 additions & 1 deletion src/io/openshift/Plugins.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package io.openshift
import io.openshift.plugins.*
import static io.openshift.Utils.pluginAvailable

class Plugins implements Serializable {
static def register() {
new analytics().register()
if (pluginAvailable("bayesian")){
new analytics().register()
}
}
}

8 changes: 8 additions & 0 deletions src/io/openshift/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,12 @@ class Utils {
}
}

static def pluginAvailable(pluginName) {
return getAllPlugins().contains(pluginName)
}

static def getAllPlugins() {
return jenkins.model.Jenkins.instance.getPluginManager().getPlugins().collect {it.getShortName()}
}

}

0 comments on commit 18476da

Please sign in to comment.