|
pipeline {
stages {
stage("Deploy") {
//Next line needs to be removed pending SSH Plugin fixes
sshPublisher(publishers: [sshPublisherDesc(configName: "MyApplication_${env.ENVIRONMENT}", transfers: [sshTransfer(excludes: '', execCommand: "rd /s /q E:\\Absolute\\path\\to\\MyApplication", execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
sshPublisher(publishers: [sshPublisherDesc(configName: "MyApplication_${env.ENVIRONMENT}", transfers: [sshTransfer(excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: true, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: "${env.RELATIVE_REMOTE_FOLDER}", remoteDirectorySDF: false, removePrefix: 'parameterisedpackage', sourceFiles: '/parameterisedpackage/**')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false, cleanRemote: true)])
}
}
}
The first sshPublisher line is the nasty workaround at the moment to remove the remote directory but it has to be an absolute path with is not going to be work as the drive letter is different across test environments. This line has the effect of deleting the entire remote directory on the target machine and its contents recursively. The second sshPublisher line copies the required files but the cleanRemote: true doesn't do anything in the remote directory on the target machine. I would like cleanRemote to respect the RELATIVE_REMOTE_FOLDER in the remoteDirectory field (which the copying function part of the plugin is) and delete the entire remote directory on the target machine and its contents recursively. |