Sar*_*ica 4 jenkins jenkins-pipeline
我有一些代码需要tox
在不同的OS上运行(实际上是构建,测试和打包,但例如只是在运行)。目前,我的Jenkinsfile
样子是这样的:
pipeline {
// Where to run stuff.
agent {
node {
label 'CentOS7'
customWorkspace '/home/build/jenkins/workspace/pipelines/ook'
}
}
// What to run goes here.
stages {
stage('Tox') {
steps {
sh 'tox -v --recreate'
}
}
}
// Clean up after ourselves.
post {
failure {
mail subject: "\u2639 ${env.JOB_NAME} (${env.BUILD_NUMBER}) has failed",
body: """Build ${env.BUILD_URL} is failing!
Somebody should do something about that\u2026""",
to: "devs@example.com",
replyTo: "devs@example.com",
from: 'jenkins@example.com'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
中间一点,我想在两种不同的系统上运行nodes
:一种用于OS 1,一种用于OS 2。
我怎么做?
当然,您希望以某种方式标记您的从属节点。我没有查找什么是tox,但是可能像“ os_linux”和“ os_mac”一样,然后可以使用node
Jenkinsfile中的步骤在每个从属服务器的上下文中运行一些命令。所以您的Tox阶段可能看起来像:
stage('Tox') {
steps {
node('os_linux') {
sh 'tox -v --recreate'
}
node('os_mac') {
sh 'tox -v --recreate'
}
}
}
Run Code Online (Sandbox Code Playgroud)
这将以串行方式运行任务,并且Jenkinsfile语法还支持在不同节点上并行执行这两个tox命令。使用Jenkins UI左侧导航栏中的“管道语法”链接(仅在管道作业上)与node
和一起使用parallel
。继续前进。
归档时间: |
|
查看次数: |
12050 次 |
最近记录: |