代码拉取完成,页面将自动刷新
同步操作将从 binvong/SCP-firmware 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
@NonCPS
List generateMatrix(Map matrixAxes) {
List axes = []
matrixAxes.each { axis, values ->
List axisList = []
values.each { value ->
axisList << [(axis): value]
}
axes << axisList
}
axes.combinations()*.sum()
}
pipeline {
agent {
label 'docker'
}
stages {
stage('Build container') {
steps {
/*
* Using `--target` with the Dockerfile agent currently bugs out
* on Jenkins, producing an error along the lines of:
*
* Cannot retrieve .Id from 'docker inspect ...'
*
* Apparently it doesn't like multi-stage builds, so until
* we're on a version of the Docker workflow plugin that
* doesn't exhibit this bug, we just have to build the image
* ourselves.
*
* See:
* - https://github.com/jenkinsci/docker-workflow-plugin/pull/149
* - https://github.com/jenkinsci/docker-workflow-plugin/pull/162
* - https://github.com/jenkinsci/docker-workflow-plugin/pull/180
*
* Once the Docker workflow plugin has been updated, we should
* be able to get rid of this stage and use:
*
* agent {
* dockerfile {
* dir 'docker'
* filename 'Dockerfile'
* additionalBuildArgs '--target ci'
* }
* }
*/
sh """ \
docker build -t scp-firmware:build-${currentBuild.number} \
--build-arg JENKINS_UID=1000 \
--build-arg JENKINS_GID=36293 \
--target=jenkins docker
"""
}
}
stage('Run tests') {
parallel {
stage('Run legacy tests') {
agent {
docker {
image "scp-firmware:build-${currentBuild.number}"
args '-e ARMLMD_LICENSE_FILE'
}
}
steps {
sh '/usr/local/bin/init'
sh 'python3 ./tools/ci.py'
}
}
stage('Build and test') {
/*
* We are on an old enough version of the Jenkins pipeline
* workflow plugin that we do not have support for matrices.
*
* Without this support, we need to generate the stages as
* part of a scripted stage.
*
* See:
* - https://www.jenkins.io/blog/2019/11/22/welcome-to-the-matrix/
* - https://www.jenkins.io/blog/2019/12/02/matrix-building-with-scripted-pipeline/
* - https://stackoverflow.com/questions/60829465/jenkins-unknown-stage-section-matrix-in-declarative-pipeline
*
* Once the plugin has been updated, we can adopt a proper
* matrix.
*/
steps {
script {
/*
* This is, admittedly, not particularly clean, but
* should require very little adjustment. The
* premise is relatively simple: generate a list of
* all the possible matrix combinations, create a
* a list of closures returning a pipeline stage for
* each combination, then execute them in parallel.
*/
def axes = [
generator: [ 'Ninja', 'Unix Makefiles' ],
buildType: [ 'Debug', 'Release', 'MinSizeRel',
'RelWithDebInfo' ]
]
def tasks = generateMatrix(axes).collectEntries { config ->
["Build and test (${config})", {
node('docker') {
docker
.image("scp-firmware:build-${currentBuild.number}")
.inside('-e ARMLMD_LICENSE_FILE')
{
/*
* If you need to adjust the
* behaviour of the generated stages
* then this is probably where you
* want to do it.
*/
stage("Build ${config}") {
checkout scm
/*
* Unfortunately, we don't have
* the CMake build plugin
* available to us, so we'll
* have to make do with shell
* scripts for now.
*/
sh '/usr/local/bin/init'
sh """ \
cmake \
-G "${config.generator}" \
-DCMAKE_BUILD_TYPE="${config.buildType}" \
.
"""
sh 'cmake --build .'
}
stage("Check ${config}") {
sh """
cmake
--build . \
--target check
"""
}
}
}
}]
}
parallel tasks
}
}
}
}
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。