我可以使用SSH管道步骤插件在一个jenkins管道中使用多个遥控器吗?
现在我的管道看起来像这样:
def remote = [:]
remote.name = 'PRE-DEV'
remote.host = 'x.x.x.x'
remote.user = 'jenkins'
remote.identityFile = '/var/lib/jenkins/.ssh/id_rsa'
remote.allowAnyHosts = true
remote.agentForwarding = true
pipeline {
agent any
stages{
stage('BUILD'){
steps{
sshCommand remote: remote, command: "build commands"
}
}
stage('UNIT TESTS'){
steps{
sshCommand remote: remote, command: "tests commands"
}
}
stage('DEPLOY TO DEV'){
steps{
sshCommand remote: remote, command: "scp artifacts push to other vm"
}
}
}
字符串
现在我需要额外的stage('RUN ON DEV'),在这里我可以在其他VM上运行我的工件。我如何在同一个管道中完成它?
1条答案
按热度按时间jjhzyzn01#
解决方案一:
你可以定义另一个像blow这样的dict:
字符串
然后通过
sshCommand remote: secondRemote, command: "your new command"
使用它解决方案二:
将私钥存储在jenkins凭据中,然后使用ssh-agent插件。
https://www.jenkins.io/doc/pipeline/steps/ssh-agent/