Skip to content

Commit 18476da

Browse files
committed
Feature to register analytics plugin only if available
This patch will add a feature to register Analytics Plugin only if it is there in jenkins Fixes #74
1 parent 868a674 commit 18476da

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ This is the API where you provide configurations like runtime or something like
179179

180180
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
181181

182+
183+
**Variables Configured in Pipeline**
184+
185+
| Name | Required | Default Value | Description |
186+
|-----------------------|------------|-----------------|-----------------------------------------------------|
187+
| runtime | false | none | runtime of the application ex java, node, go etc. |
188+
| version | false | none | version of the runtime using |
189+
182190
### ci
183191

184192
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
@@ -252,6 +260,8 @@ as `params`.
252260
Following template parameters must be present in the template and is set to the
253261
following values by default. You can override them by passing key value pairs in params.
254262

263+
**Template Parameters**
264+
255265
| Name | Default Value |
256266
|-----------------------------|------------------------------------------|
257267
| SUFFIX_NAME | branch name |
@@ -276,8 +286,8 @@ This API can read multiple resources separated by `---` from the yaml file.
276286

277287
| Name | Required | Default Value | Description |
278288
|----------------|------------|------------------------------|------------------------------------------------------------------------|
279-
| file | true | none | An relative path of resource yaml file. |
280-
| validate | false | true | A validation for resource yaml file. |
289+
| file | true | none | An relative path of resource yaml file. |
290+
| validate | false | true | A validation for resource yaml file. |
281291

282292
### build
283293

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

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

src/io/openshift/Plugins.groovy

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package io.openshift
22
import io.openshift.plugins.*
3+
import static io.openshift.Utils.pluginAvailable
34

45
class Plugins implements Serializable {
56
static def register() {
6-
new analytics().register()
7+
if (pluginAvailable("bayesian")){
8+
new analytics().register()
9+
}
710
}
811
}
912

src/io/openshift/Utils.groovy

+8
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,12 @@ class Utils {
122122
}
123123
}
124124

125+
static def pluginAvailable(pluginName) {
126+
return getAllPlugins().contains(pluginName)
127+
}
128+
129+
static def getAllPlugins() {
130+
return jenkins.model.Jenkins.instance.getPluginManager().getPlugins().collect {it.getShortName()}
131+
}
132+
125133
}

0 commit comments

Comments
 (0)