59 lines
1.6 KiB
Markdown
59 lines
1.6 KiB
Markdown
# Helper class for Jenkins
|
|
|
|
This repo add functionality for automate building with `platforms.json` configuration.
|
|
|
|
## Setup
|
|
|
|
You should add `PLATFORMS_GIT` environment to your Jenkins with url to git repo, which
|
|
contains single `platforms.json` file.
|
|
|
|
Next you should register this library in Jenkins -> System settings -> Global Pipeline Libraries:
|
|
* Library name: `SHS.Platforms`
|
|
* Default version: `master`
|
|
* Project Repository: `https://git.shs.tools/SHS/jenkins_lib.git`
|
|
|
|
## API
|
|
|
|
`org.SHS.Platforms` Class:
|
|
* `get()` - download and parse `platforms.json` file from `PLATFORMS_GIT`
|
|
* `root()` - returns root JSON object of `platforms.json`
|
|
* `forEach(func, ...)` - iterate over platforms, `func` is only mandatory parameter:
|
|
* `func` - method to execute for each enabled platform, pass JSON element of current platform
|
|
* `stagePrefix` - prefix string for `stage`
|
|
* `stageSuffix` - sufffix string for `stage`
|
|
* `whiteList` - array of permitted names, ignored if empty
|
|
* `blackList` - array of denied names, ignored if empty
|
|
|
|
`whiteList` and `blackList` are case-insensitive, and can be part of platform name
|
|
|
|
## Usage
|
|
|
|
Simple:
|
|
```
|
|
@Library('SHS.Platforms') _
|
|
node {
|
|
def pl = new org.SHS.Platforms(this)
|
|
pl.get()
|
|
pl.forEach ({ dist ->
|
|
print("works in ${dist.docker_image}")
|
|
})
|
|
}
|
|
```
|
|
|
|
With filter:
|
|
```
|
|
@Library('SHS.Platforms') _
|
|
node {
|
|
def pl = new org.SHS.Platforms(this)
|
|
pl.get()
|
|
pl.forEach ({ dist ->
|
|
print("works in ${dist.docker_image}")
|
|
},
|
|
stagePrefix: "Build ",
|
|
stageSuffix: " soft",
|
|
whiteList: ["ubuntu", "debian", "osx"],
|
|
blackList: ["20.04", "11"]
|
|
)
|
|
}
|
|
```
|