我在Jenkins中创建了一个作业来运行一个shell脚本"QIDS_Report_Deploy.sh"
,它基本上将JAR文件从一个位置移动到“部署位置”。
我第一次尝试执行shell脚本时,也得到了预期的结果。
然后,我需要运行另一个脚本来使用"QIDSReport_Install.sh"
运行JAR文件,所以我刚刚在Jenkins job config的“Execute shell”文本区域中为"QIDS_Report_Deploy.sh"
创建的同一个作业中更改了命令。引发以下错误失败:-
Building in workspace /opt/apps/data/Jenkins_2_138_3/.jenkins/workspace/QIDs_REPORT_INSTALL
[QIDs_REPORT_INSTALL] $ /bin/sh -xe /var/tmp/jenkins1438807827969815358.sh
+ /opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDSReport_Install.sh itg
/var/tmp/jenkins1438807827969815358.sh[2]: /opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDSReport_Install.sh: not found.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
在此之后,我将对Execute Shell部分的命令部分所做的更改从以下位置还原:-
/opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDSReport_Install.sh itg
到
/opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDS_Report_Deploy.sh itg
现在,以前工作的内容(QIDS_Report_Deploy.sh)也不工作,这会引发以下错误:-
/opt/apps/data/Jenkins_2_138_3/.jenkins/workspace/QIDs_REPORT_INSTALL
[QIDs_REPORT_INSTALL] $ /bin/sh -xe /var/tmp/jenkins1438807827969815360.sh
+ /opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDSReport_Install.sh itg
/var/tmp/jenkins1438807827969815360.sh[2]: /opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDS_Report_Deploy.sh: not found.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
在我遇到这个问题之后,我删除了这个作业,并为执行每个shell脚本创建了两个新的独立作业,但是它现在仍然抛出相同的错误
如果你想让我解释这个问题,请告诉我。
注:-
脚本的第一行是
#!/bin/sh
两个文件的权限均
chmod 777
最佳答案
当您直接给出命令而不是shell名称时,Jenkins execute shell将更加可靠。
当你决定去壳牌,确保它存在。
在上面
+/opt/apps/corona/loads/SvnService/QIDSReportV2_3HPE/QIDSReport_Install.sh选项
未找到说明,外壳不存在或许可不存在
使用ls-lrt检查文件和权限,然后重试
关于java - 如何让Jenkins查找作业中指定的shell脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58486819/