如何在sshagent内部的jenkinsfile中使用变量?
关于stackoverflow上的类似问题有很多线程,但它们无法帮助我处理我的具体情况:
node{
def USER = "user"
def ADRESS= "adress"
def ARGUMENT= "argument"
stage('test'){
sshagent(['123123']) {
sh 'ssh ${USER}@${ADRESS} "command ${ARGUMENT} && command"'
}
}
}
在控制台输出$ {user}和$ {adress}和$ {adress}将下降到一个空字符串,但$ {groment}将下降到“参数” ”。我必须如何格式化这些占位符的工作?我已经尝试了所有我能找到的一切,但似乎没有任何作用。
There are many threads about similiar problems on stackoverflow but they couldn't help me with my specific case:
node{
def USER = "user"
def ADRESS= "adress"
def ARGUMENT= "argument"
stage('test'){
sshagent(['123123']) {
sh 'ssh ${USER}@${ADRESS} "command ${ARGUMENT} && command"'
}
}
}
In the console output ${USER} and ${ADRESS} will resolve to an empty string but ${ARGUMENT} will resolve to "argument". How do I have to format these placeholders that they work? I have tried everything I could find but nothing seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@noamhelmer指出的那样:
sh“ ssh $ {user} @$ {adress} \”“命令$ {gright}&& command \“”
works。
As @NoamHelmer pointed out:
sh "ssh ${USER}@${ADRESS} \""command ${ARGUMENT} && command\""
works.