[英]Execute shell script from Jenkins Pipeline
I am trying to execute shell script from my jenkins pipeline.我正在尝试从我的 jenkins 管道执行 shell 脚本。 I have provided absolute and relative path in the shell command and still I am facing
No such file or directory
error while building the pipeline.我在 shell 命令中提供了绝对和相对路径,但在构建管道时我仍然面临
No such file or directory
错误。
This is simple script but yet not working.这是一个简单的脚本,但还没有工作。
Try 1:尝试1:
stage ( 'Executing shell script' ) {
steps {
sh '/home/patching/shell_script.sh'
}
}
Try 2:尝试2:
stage ( 'Executing shell script' ) {
steps {
sh './shell_script.sh'
}
}
Try 3:尝试3:
stage ( 'Executing shell script' ) {
steps {
dir ('/home/patching/shell_script.sh){
sh './shell_script.sh'
}
}
I really don't know what is really wrong with the script.我真的不知道剧本到底出了什么问题。 Could some one help me on this?
有人可以帮助我吗?
I got the issue why it wasn't able to find the file that I wanted to run.我得到了为什么它无法找到我想要运行的文件的问题。 It was running on different slave.
它在不同的奴隶上运行。
Can you try this你能试试这个
pipeline {
agent any
stages {
stage('Hello World') {
steps {
script {
sh '''
/home/ubuntu/First.sh
'''
}
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.