jenkins的pipline脚本如何设置sshPut覆盖传输
要设置sshPut覆盖传输,可以使用以下代码:
sshPut remote: 'remote/path/to/file', file: 'local/path/to/file', overwrite: true
在这个代码中,我们将overwrite参数设置为true,这将覆盖远程服务器上已有的文件。如果将overwrite参数设置为false(默认值),则当远程服务器上已存在同名文件时,sshPut将失败并抛出异常。
完整的pipline脚本示例:
pipeline {
agent any
stages {
stage('Transfer Files') {
steps {
sshagent(['my-ssh-key']) {
sshPut remote: 'remote/path/to/file', file: 'local/path/to/file', overwrite: true
}
}
}
}
}
``
原文地址: https://www.cveoy.top/t/topic/cSDI 著作权归作者所有。请勿转载和采集!