8cb3680eeb30c529cf55539ab27463ffc80e78bc
Helper class for Jenkins
This repo add functionality for automate building with platforms.json configuration.
Setup
You should add PLATFORMS_GIT and PLATFORMS_FILTER_GIT environment to your Jenkins with url to git repo, which
contains single platforms.json and filter.json file.
PLATFORMS_GIT -> platforms.json
PLATFORMS_FILTER_GIT -> filter.json
Next 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:
@Library('SHS.Platforms') _
node {
properties([copyArtifactPermission('*')])
def pl = new org.SHS.Platforms(this)
pl.createLocal()
}
If you want to copy final json to host, add
pl.copyToHost('/your/path/platforms.json')
API
org.SHS.Platforms Class:
createLocal()- download and parseplatforms.jsonfromPLATFORMS_GITandfilter.jsonfromPLATFORMS_FILTER_GIT, filter/prepare final JSON and save it to artifactcopyToHost(path)- call after createLocal() to copy final JSON topathon your hostget()- read and parseplatforms_local.jsonfile from "shstk-platforms" artifactroot()- returns root JSON object ofplatforms.jsonforEach(func, ...)- iterate over platforms,funcis only mandatory parameter:func- method to execute for each enabled platform, pass JSON element of current platform and optional CMake toolchain argumentstagePrefix- prefix string forstagestageSuffix- suffix string forstagewhiteList- array of permitted names, ignored if emptyblackList- array of denied names, ignored if emptyondemand- if true then process also ondemand platforms
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_basename}")
})
}
With toolchain:
@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:
@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"]
)
}
Description
Languages
Groovy
100%