I am trying to execute several command with Pipeline with SSHCommand but I'am not able to do what I want :
pipeline {
agent any
stages {
stage('Generate File') {
steps {
script {
def remote = [:]
remote.name = 'test'
remote.host = 'xxxxxxx'
remote.user = 'xxxxxxx'
remote.port = xxxxxxxx
remote.password = 'xxxxxxxx'
remote.allowAnyHosts = true
sshCommand remote: remote, command: "cd /var/my/directory"
sshCommand remote: remote, command: "touch pipeline"
}
}
}
}
}
But the file "pipeline" is created in "/home/myUser" not in /var/my/directory"
How can i do this ? I need to use "&&" ?
This works :
sshCommand remote: remote, command: "cd /var/my/directory && touch MyFile"
But I don't like "single line"
Thanks,