没有什么能阻止你使用Jenkins pipeline DSL。
我们有相同的管道并行运行,以便为公开 Web 服务、为多个外部应用程序提供数据库、通过多个工作队列接收数据并具有 GUI 前端的应用程序的组合负载建模。业务向我们提供了应用程序必须满足的非功能性要求 (NFR),即使在繁忙时间也能保证其响应能力。
管道的不同实例使用不同的参数运行。第一个实例可能是WS_Load,第二个实例是GUI_Load,第三个实例是Daily_Update_Load,对需要在特定时间范围内处理的大型数据队列进行建模。根据我们要测试的负载组合,可以添加更多。
其他答案都谈到了并发构建的复选框,但我想提另一个问题:资源争用。
如果您的流水线在流水线阶段之间使用临时文件或stashes 文件,则实例最终可能会从彼此的脚下拉扯地毯。例如,您最终可能会在一个并发实例中删除一个文件,同时尝试在另一个实例中读取相同的文件。我们使用以下代码来确保每个并发实例的存储和临时文件名是唯一的:
def concurrentStash(stashName, String includes) {
/* make a stash unique to this pipeline and build
that can be unstashed using concurrentUnstash() */
echo "Safe stashing $includes in ${concurrentSafeName(stashName)}..."
stash name: concurrentSafeName(stashName), includes: includes
}
def concurrentSafeName(name) {
/* make a name or name component unique to this pipeline and build
* guards against contention caused by two or more builds from the same
* Jenkinsfile trying to:
* - read/write/delete the same file
* - stash/unstash under the same name
*/
"${name}-${BUILD_NUMBER}-${JOB_NAME}"
}
def concurrentUnstash(stashName) {
echo "Safe unstashing ${concurrentSafeName(stashName)}..."
unstash name: concurrentSafeName(stashName)
}
然后我们可以使用concurrentStash stashName和concurrentUnstash stashName,并发实例不会冲突。
如果两个管道都需要存储统计信息,我们可以对文件名执行以下操作:
def statsDir = concurrentSafeName('stats')
然后每个实例将使用唯一的文件名来存储它们的输出。