如何在sshagent内部的jenkinsfile中使用变量?

发布于 2025-02-13 04:47:33 字数 404 浏览 0 评论 0原文

关于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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏璃陌 2025-02-20 04:47:33

正如@noamhelmer指出的那样:

sh“ ssh $ {user} @$ {adress} \”“命令$ {gright}&& command \“”

works。

As @NoamHelmer pointed out:

sh "ssh ${USER}@${ADRESS} \""command ${ARGUMENT} && command\""

works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文