diff --git a/README.md b/README.md index 020a925..a6915ae 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ You should add `PLATFORMS_GIT` environment to your Jenkins with url to git repo, contains single `platforms.json` file. Next you should register this library in Jenkins -> System settings -> Global Pipeline Libraries: -* Library name: `SHS` +* Library name: `SHS.Platforms` * Default version: `master` * Project Repository: `https://git.shs.tools/SHS/jenkins_lib.git` ## Usage ``` -@Library('SHS') _ +@Library('SHS.Platforms') _ node { def pl = new org.SHS.Platforms(this) pl.get() @@ -26,4 +26,5 @@ node { ``` `dist` is JSON element of current platform + `"-test"` is a stage suffix diff --git a/src/org/SHS/Platforms.groovy b/src/org/SHS/Platforms.groovy index 70d4dcd..3f454e9 100644 --- a/src/org/SHS/Platforms.groovy +++ b/src/org/SHS/Platforms.groovy @@ -2,6 +2,7 @@ package org.SHS class Platforms { def steps + def _root public Platforms(steps) {this.steps = steps} @@ -10,15 +11,17 @@ class Platforms { steps.dir("platforms_git") { steps.deleteDir() steps.git url: "${steps.env.PLATFORMS_GIT}" + this._root = steps.readJSON(file: 'platforms_git/platforms.json') } } } - public void forEach(functor, stage_suffix = "") { - def root = steps.readJSON(file: 'platforms_git/platforms.json') - root.Platforms.each { key, dist -> + public def root() {return _root;} + + public void forEach(functor, stageSuffix = "", whiteList = [], blackList = []) { + _root.Platforms.each { key, dist -> if (dist.enabled) { - steps.stage ("${key}${stage_suffix}") { + steps.stage ("${key}${stageSuffix}") { functor(dist) } }