# Helper class for Jenkins This repo add functionality for automate building with `platforms.json` configuration. ## Setup You should register this library in Jenkins -> System settings -> Global Pipeline Libraries: * Library name: `SHS.Platforms` * Default version: `master` * Project Repository: `https://git.shstk.ru/SHS/jenkins_lib.git` Then create pipeline job with fixed name `shstk-platforms` and set script to: ```js @Library('SHS.Platforms') _ node { properties([copyArtifactPermission('*')]) def pl = new org.SHS.Platforms(this) // First download 'platforms.json' source file // Download from 'https://git.shstk.ru/SHS/platforms.git' pl.download() // OR // Download from your git pl.download('https://my.git.address/my/repo.git') // Optionally filter with your lists pl.filter(whiteList: ['filter1', 'filter2'], blackList: ['filter3']) // Optionally mark platforms as 'ondemand' with your lists pl.setOndemand(whiteList: ['filter4', 'filter5'], blackList: ['filter6']) // Compile JSON and save as artifact pl.create() // Optionally copy to your host location pl.copyToHost('/your/path/platforms.json') } ``` ## API `org.SHS.Platforms` Class: * `download()` - download `platforms.json` from 'https://git.shstk.ru/SHS/platforms.git' or custom git address * `filter()` - filter with white/black lists * `setOndemand()` - mark as 'ondemand' with white/black lists * `create()` - compile final JSON and save it to artifact * `copyToHost(path)` - copy final JSON to `path` on your host * `get()` - read and parse `platforms_local.json` file from "shstk-platforms" artifact * `root()` - returns 'platforms' object of current platforms * `forEach(func, ...)` - iterate over platforms, `func` is only mandatory parameter: * `func` - method to execute for each enabled platform, pass JSON element of current platform and optional CMake toolchain argument * `stagePrefix` - prefix string for `stage` * `stageSuffix` - suffix string for `stage` * `whiteList` - array of permitted names, ignored if empty * `blackList` - array of denied names, ignored if empty * `ondemand` - if true then process also ondemand platforms `whiteList` and `blackList` are case-insensitive, and can be part of platform name ## Usage Simple: ```js @Library('SHS.Platforms') _ node { def pl = new org.SHS.Platforms(this) pl.get() pl.forEach ({ dist -> print("works in ${dist.docker.image_basename}") }) } ``` With toolchain: ```js @Library('SHS.Platforms') _ node { def pl = new org.SHS.Platforms(this) pl.get() pl.forEach ({ dist, cmake_toolchain -> print("compile in ${dist.docker.image_basename} with arg ${cmake_toolchain}") }) } ``` With white/black lists: ```js @Library('SHS.Platforms') _ node { def pl = new org.SHS.Platforms(this) pl.get() pl.forEach ({ dist -> print("works in ${dist.docker.image_basename}") }, stagePrefix: "Build ", stageSuffix: " soft", whiteList: ["ubuntu", "debian", "osx"], blackList: ["20.04", "11"] ) } ```