admin管理员组文章数量:1307006
I have a pipeline that runs a Windows container and can run in different nodes. Each node has a different amount of threads. Because of Hiper-V isolation in Windows, I only get two cores on each container by default, although the host machine has more than two. My idea is to configure each Jenkins node to have an environmental variable telling how many threads you can use:
Then, I can use the env.CORES
variable to set the --cpus
flags in the docker:
pipeline {
agent {
docker {
image 'mcr.microsoft/dotnet/framework/runtime:4.8'
args '--pull always'
label 'windows-build'
}
}
stages {
stage('Prepare') {
steps {
echo 'Node name: ' + env.NODE_NAME
echo 'CORES: ' + env.CORES
}
}
}
}
However, at the time of running the docker, it fails as the env.CORES
variable is null
.
Any idea on how to do so? I have thought and given some tries to read the host machine environmental variable NUMBER_OF_PROCESSORS
(link) but apparently, the problem is that at that time the Jenkins node is not yet assigned....
本文标签: windowsJenkins pipeline using docker set the cpus flag from an environmental variableStack Overflow
版权声明:本文标题:windows - Jenkins pipeline using docker set the --cpus flag from an environmental variable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741832326a2400006.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论