jenkins多job并发
Posted opama
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jenkins多job并发相关的知识,希望对你有一定的参考价值。
现在大系统都是用一个deploy job去部署,在pipeline里面配置了多个job,运行时间很长,所以考虑优化一下
stage (\'scrm deploy jobs\'){
build job: \'perf.scrm.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_branch\', value: params.scrm_branch]]
build job: \'perf.scrm-credit-base.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_credit_base_branch\', value: params.scrm_credit_base_branch]]
build job: \'perf.scrm-credit-core.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_credit_core_branch\', value: params.scrm_credit_core_branch]]
build job: \'perf.scrm-funds-core.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_funds_core_branch\', value: params.scrm_funds_core_branch]]
build job: \'perf.customerbase.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'customerbase_branch\', value: params.customerbase_branch]]
build job: \'perf.scrm-gateway.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'gateway_branch\', value: params.gateway_branch]]
build job: \'perf.scrm-behavior.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]]
build job: \'perf.scrm-behavior-job.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]]
build job: \'perf.scrm-search-core.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]]
build job: \'perf.scrm-search-job.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]]
build job: \'perf.scrm-customer-core-j.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'scrm_customer_core_j_branch\', value: params.scrm_customer_core_j_branch]]
}
看了下jenkins里面的语法提示
改造成并发比较容易,不过考虑到有些模块之间的依赖关系,所以分组设置,不同组之间可以并发部署
stage (\'scrm deploy jobs\'){ parallel \'scrm.deploy\':{ build job: \'perf.scrm.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_branch\', value: params.scrm_branch]] },\'scrm-credit\':{ build job: \'perf.scrm-credit-base.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_credit_base_branch\', value: params.scrm_credit_base_branch]] build job: \'perf.scrm-credit-core.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_credit_core_branch\', value: params.scrm_credit_core_branch]] },\'scrm-funds\':{ build job: \'perf.scrm-funds-core.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'scrm_funds_core_branch\', value: params.scrm_funds_core_branch]] },\'scrm-customer\':{ build job: \'perf.scrm-customer-core-j.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'scrm_customer_core_j_branch\', value: params.scrm_customer_core_j_branch]] build job: \'perf.customerbase.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'customerbase_branch\', value: params.customerbase_branch]] },\'scrm-gateway\':{ build job: \'perf.scrm-gateway.deploy\',parameters: [[$class: \'StringParameterValue\', name: \'gateway_branch\', value: params.gateway_branch]] },\'scrm-behavior\':{ build job: \'perf.scrm-behavior.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]] build job: \'perf.scrm-behavior-job.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]] },\'scrm-search\':{ build job: \'perf.scrm-search-core.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]] build job: \'perf.scrm-search-job.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'behavior_branch\', value: params.behavior_branch]] },\'scrm-benefit\':{ build job: \'perf.benefit-core.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'core_branch\', value: params.scrm_benefit_branch]] build job: \'perf.benefit-base.deploy\',parameters : [[$class: \'StringParameterValue\', name: \'base_branch\', value: params.scrm_benefit_branch]] } }
执行后查看,各个分组已经可以同时运行
最后查看执行时间,缩短了80%
以上是关于jenkins多job并发的主要内容,如果未能解决你的问题,请参考以下文章