一个jenkins管道中有多个ssh远程
我可以使用SSH管道步骤插件在一个jenkins管道中使用多个遥控器吗 现在,我的管道如下所示:一个jenkins管道中有多个ssh远程,jenkins,groovy,continuous-integration,jenkins-pipeline,jenkins-plugins,Jenkins,Groovy,Continuous Integration,Jenkins Pipeline,Jenkins Plugins,我可以使用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
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"
}
}
}
现在我需要额外的阶段(“在DEV上运行”),在这里我可以在其他VM上运行我的工件。如何在同一管道中执行此操作?解决方案一:
你可以定义另一个类似口述的打击:
def secondRemote = [:]
secondRemote.name = 'PRE-DEV'
secondRemote.host = 'your new host'
secondRemote.user = 'jenkins'
secondRemote.identityFile = '/var/lib/jenkins/.ssh/id_rsa'
secondRemote.allowAnyHosts = true
secondRemote.agentForwarding = true
然后用它
sshCommand remote:secondRemote,命令:“您的新命令”
解决方案二:
将您的私钥存储在jenkins凭据中,然后使用ssh代理插件
解决方案一:
你可以定义另一个类似口述的打击:
def secondRemote = [:]
secondRemote.name = 'PRE-DEV'
secondRemote.host = 'your new host'
secondRemote.user = 'jenkins'
secondRemote.identityFile = '/var/lib/jenkins/.ssh/id_rsa'
secondRemote.allowAnyHosts = true
secondRemote.agentForwarding = true
然后用它
sshCommand remote:secondRemote,命令:“您的新命令”
解决方案二:
将您的私钥存储在jenkins凭据中,然后使用ssh代理插件