詹金斯 - “sh”拆分我的命令并尝试单独执行它
我正在尝试使用SH在Jenkins管道中运行Linux命令,但是由于某种原因,我的命令被吐了2个,并试图稀少地执行它们。 管道的结果是: curl - Insecure -U' : ' - upload -file ./file.ear 卷发:未指定URL! 请参阅图像。
pipeline {
agent any
stages {
stage('use curl'){
steps{
script{
withCredentials([
usernamePassword(credentialsId: 'CREDENTIALS', usernameVariable: 'USER', passwordVariable: 'PWD')
]) {
sh(script:"curl --insecure -u ${USER}:${PWD} --upload-file ./" + Artifact + " " + REPO_URL + Artifact.substring(0, Artifact.length() - 5) + "/", returnStdout: false)
} //withCredentials
} // scripts
} //steps
} //stage
}
}
I am trying to run a linux command in a jenkins pipeline using sh, but for some reason my command get's spited in 2 and tries to execute them sparely.
The result of the pipeline is:
curl --insecure -u ':' --upload-file ./file.ear
curl: no URL specified!
Please see the image.
pipeline {
agent any
stages {
stage('use curl'){
steps{
script{
withCredentials([
usernamePassword(credentialsId: 'CREDENTIALS', usernameVariable: 'USER', passwordVariable: 'PWD')
]) {
sh(script:"curl --insecure -u ${USER}:${PWD} --upload-file ./" + Artifact + " " + REPO_URL + Artifact.substring(0, Artifact.length() - 5) + "/", returnStdout: false)
} //withCredentials
} // scripts
} //steps
} //stage
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
artifact.trim()
没有修复它。但是使用artrifact.substring(0,artifact.length()-1)
而不是做到了。Using
Artifact.trim()
did not fix it. But usingArtrifact.substring(0, Artifact.length() - 1)
instead did the trick.