fb365926972d812b251bc8248ec35aeb6751c375
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:
@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()- downloadplatforms.jsonfrom 'https://git.shstk.ru/SHS/platforms.git' or custom git addressfilter()- filter with white/black listssetOndemand()- mark as 'ondemand' with white/black listscreate()- compile final JSON and save it to artifactcopyToHost(path)- copy final JSON topathon your hostget()- read and parseplatforms_local.jsonfile from "shstk-platforms" artifactroot()- returns 'platforms' object of current platformsforEach(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%