readme
This commit is contained in:
38
README.md
38
README.md
@@ -12,19 +12,47 @@ Next you should register this library in Jenkins -> System settings -> Global Pi
|
||||
* 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, optional parameters:
|
||||
* `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("iterate ${dist.docker_image}")
|
||||
}, "-test")
|
||||
print("works in ${dist.docker_image}")
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
`dist` is JSON element of current platform
|
||||
|
||||
`"-test"` is a stage suffix
|
||||
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"]
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
@@ -38,9 +38,9 @@ class Platforms {
|
||||
def dn = name.toLowerCase()
|
||||
if (whiteList.size() > 0) {
|
||||
in_white = false
|
||||
whiteList.each { l -> if (dn.indexOf(l) >= 0) { in_white = true } }
|
||||
whiteList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_white = true } }
|
||||
}
|
||||
blackList.each { l -> if (dn.indexOf(l) >= 0) { in_black = true } }
|
||||
blackList.each { l -> if (dn.indexOf(l.toLowerCase()) >= 0) { in_black = true } }
|
||||
return in_white && !in_black
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user