Jenkins Pipeline ssh steps sshPut all of a file type
Answer a question
I'm trying move all of a particular file type to another server using SSH Steps. I'm specifically trying to use the sshPut to move over all .txt files. Here is the line I'm using:
sshPut remote: remote, from: "*.txt", into: "/the/destination/folder/"
and here is the error Jenkins is throwing:
java.lang.IllegalArgumentException: /the/source/folder/*.txt does not exist.
I know that I have the sshsteps setup correctly. I've been able to push a single file and run some commands on the remote server. Can sshPut even handle a wildcard? I'm trying to avoid zipping everything up and doing the unzip on the remote server, if possible, but if that's what needs to happen, that's what needs to happen. I also have strict instructions to not use ssh keys, so scp is out of the question at the moment.
Update: based on susenj's advice I change my line to:
sshPut remote: remote, from: "./", filterRegex: /\.txt$/, into: "/the/destination/folder/"
and that worked.
Answers
The regex for sshPut works with the Groovy Syntax. Please refer to : https://github.com/jenkinsci/ssh-steps-plugin#sshput
What you can try is: sshPut remote: remote, from: "./", filterRegex: /.txt$/, into: "/the/destination/folder/"
更多推荐
所有评论(0)