-
Bug
-
Resolution: Incomplete
-
Major
-
None
-
Powered by SuggestiMate
Like in the Publish over FTP plugin
[JENKINS-33056] Please add clean remote option
Code changed in jenkins
User: Alex Earl
Path:
pom.xml
src/main/java/jenkins/plugins/publish_over_ssh/BapSshClient.java
src/main/resources/jenkins/plugins/publish_over_ssh/Messages.properties
src/main/resources/jenkins/plugins/publish_over_ssh/options/SshOverrideTransferDefaults/config.jelly
src/test/java/jenkins/plugins/publish_over_ssh/BapSshClientTest.java
http://jenkins-ci.org/commit/publish-over-ssh-plugin/5b80db4f084cae85be0b7c510dafe89b18123d7b
Log:
Fix JENKINS-33056
slide_o_mix Can this functionality please be published. It seems a long time since v1.19.1 was released.
Thank you,
Andrew
github.com/agray
Thanks for this release slide_o_mix. Much appreciated.
Is this supported in Declarative Pipeline?
How is it used? Do we just add
cleanRemote: true
as an attribute on the sshPublisher() command?
Also I don't see a cleanRemote option in the Pipeline Syntax generator. Has that been implemented?
I tested cleanRemote: true in an sshPublisher() call. it passes validation and runs but doesn't do anything. Nothing is deleted in the remoteDirectory. I would expect it to delete the contents of the remoteDirectory recursively leaving it an empty directory so that the transfer then filled up the remoteDirectory again with fresh files from source.
Functionality doesn't appear to be implemented for Declarative Pipeline or shown in Pipeline Syntax Generator.
Expected to be able to add cleanRemote: true to an sshPublisher() call in declarative pipeline.
I don't use declarative so I am not sure how to use it there. I will have to refresh my memory on how it's used in pipeline. Can you attach your Jenkinsfile?
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 absolute path workaround at the moment. This line has the effect of deleting the entire remote directory on the target machine and its contents recursively. Kind of gets the job done BUT... it is not going to work well as the drive letter is different across test environments. I would like to remove this line entirely.
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 and see it execute BEFORE the transfer of new files executes.
parameterisedpackage is a result directory that has had msdeploy run to apply a properties file for the target environment over the Web.config file.
Let me know if you have any other questions.
Can you check what version of the publish-over (NOT publish-over-ssh) plugin you have installed? If it is 0.21, can you try upgrading it to 0.22?
Jenkins 2.138.1 (Latest LTS release)
I see that I already have 0.22 of the publish-over plugin installed in my Installed tab.
Infrastructure plugin for Publish Over X Send build artifacts somewhere. |
0.22 |
Ok, my bad, I didn't update one of the jelly files to allow this to work. I will add that and try and get an 1.20.1 out soon (I am getting on a plane in a few minutes so it may be tomorrow).
Thanks Alex. It is only the jelly (UI?) files?
Has this functionality been implemented for Declarative Pipeline to function as I am expecting?
If so, what should the attribute be if not "cleanRemote: true"
"clean-Remote: true"?
Many Thanks.
No, one other file got missed when I pushed. It would be cleanRemote: true. If it works for scripted, it should work for declarative. There is nothing special that needs to be done for declarative as far as I know.
As you can see from the 2nd sshPublisher() line above the cleanRemote: true appears to be totally ignored.
Monitoring the remote directory while the job executes I see no deletion of anything in the remote directory. Hence why I had to add the 1st sshPublisher() line as a workaround.
Where is this released? The latest release I see is 1.20.1. Was this release pulled?
I reopen this issue since the last published Version is 1.20.1 and it does not contain correctly working clean remote option.
For your information, all publish-over-ssh component type JENKINS issues related to the Publish Over SSH plugin have been transferred to Github: https://github.com/jenkinsci/publish-over-ssh-plugin/issues
Here is the direct link to this issue in Github: https://github.com/jenkinsci/publish-over-ssh-plugin/issues/144
And here is the link to a search for related issues: https://github.com/jenkinsci/publish-over-ssh-plugin/issues?q=%22JENKINS-33056%22
(Note: this is an automated bulk comment)
Closing ticket, please use the corresponding Github Issue as linked above.
Even though JJB lists a 'clean-remote' option, enabling it causes a "null" error when publishing. Tested with Publish over SSH plugin version 1.14.