使用sudo权限执行docker命令
This commit is contained in:
Vendored
+4
-4
@@ -53,13 +53,13 @@ pipeline {
|
||||
steps {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: "${env.credentialsId}", keyFileVariable: 'kfIdentity', passphraseVariable: 'pVariable', usernameVariable: 'userName')]) {
|
||||
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
|
||||
command: "docker stop ${env.containerName}",sudo: false ,failOnError: false)
|
||||
command: "docker stop ${env.containerName}",sudo: true ,failOnError: false)
|
||||
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
|
||||
command: "docker rm ${env.containerName}",sudo: false ,failOnError: false)
|
||||
command: "docker rm ${env.containerName}",sudo: true ,failOnError: false)
|
||||
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
|
||||
command: "docker rmi ${env.dockerRegistry}/${env.GROUP}/${env.ARTIFACTID}:${env.VERSION}",sudo: false ,failOnError: false)
|
||||
command: "docker rmi ${env.dockerRegistry}/${env.GROUP}/${env.ARTIFACTID}:${env.VERSION}",sudo: true ,failOnError: false)
|
||||
sshCommand(remote: [ name: "${env.deployName}" ,host: "${env.deployHost}" ,allowAnyHosts: true,user: "${userName}",identityFile: "${kfIdentity}" ] ,
|
||||
command: "docker run -d -p ${env.export}:8080 --name ${env.containerName} ${env.dockerRegistry}/${env.GROUP}/${env.ARTIFACTID}:${env.VERSION}",sudo: false ,failOnError: true)
|
||||
command: "docker run -d -p ${env.export}:8080 --name ${env.containerName} ${env.dockerRegistry}/${env.GROUP}/${env.ARTIFACTID}:${env.VERSION}",sudo: true ,failOnError: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user