Jenkins运行并行脚本 [英] Jenkins running parallel scripts

查看:90
本文介绍了Jenkins运行并行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是詹金斯的新手,需要一些帮助.

I am new to Jenkins and need some help..

我有4个shell脚本:test1.sh,test2.sh,test3.sh和test4.sh

I have 4 shell scripts : test1.sh, test2.sh, test3.sh and test4.sh

我希望test2.sh仅在test1.sh成功运行时运行,而test4.sh仅在test3.sh成功运行时运行. 我还希望test1.sh和test3.sh并行运行.

I want test2.sh to only run if test1.sh runs successfully and test4.sh to only run if test3.sh runs successfully. I also want test1.sh and test3.sh to run in parallel.

我如何在詹金斯实现它?

How could I achieve it in Jenkins?

我正在使用使用ssh在远程主机上执行shell脚本"和有条件的步骤(多个)"(只是进行探索).我还设置了密钥,以便与远程服务器通信.

I am using "Execute shell script on remote host using ssh" and "Conditional steps(multiple)" (just exploring). I have also set up keys so as to communicate with remote server.

使用屏幕快照或其他方式进行插图会很有帮助.

Illustration using screen shot or other way would be helpful.

谢谢!

推荐答案

首先,确保test1.sh和test3.sh成功时返回标准成功代码(0).然后,可以在任何命令行(不仅是Jenkins)上运行的简单方法是使用以下命令行:

First, ensure that test1.sh and test3.sh return the standard success code when they succeed (0). Then the simple way, which works in any command line, not just Jenkins, is to use this command line:

((test1.sh && test2.sh) &) ; ((test3.sh && test4.sh) &)

每对括号都形成一个子shell,双&"号表示如果先成功则运行第二",而单&"号表示在backgorund中运行".因此,您将获得相当于两个后台外壳程序的外壳程序,每个外壳程序运行两个脚本,如果第一个脚本不返回0,则将退出.

Each pair of parentheses forms a subshell, double-amperands mean "if first succeeds then run second", and single ampersand mean "run in backgorund". So you get the equivalent of two backgrounded shells each running two scripts, which will exit if the first script doesn't return 0.

Jenkins特定的解决方案是使一个节点具有两个(或更多)跑步者.创建两个作业,然后将两个作业都绑定到该节点.每个作业都运行一个单独的外壳,即test1.sh && test2.shtest3.sh && test4.sh.

The Jenkins-specific solution is to have a node with two (or more) runners. Create two jobs, and tie both to that node. Each job runs a single shell, either test1.sh && test2.sh, or test3.sh && test4.sh.

这篇关于Jenkins运行并行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆