SSH Pipeline Steps: Multiline script has no output

413 views
Skip to first unread message

Sverre Moe

unread,
Jan 19, 2022, 6:33:24 AM1/19/22
to Jenkins Users
When I have a script with multiple lines, I do not get any output from the script in the console output of the pipeline job.


pipeline {
  agent {
    label 'docker-agent'
  }
  environment {
    SERVER_CREDS = credentials('server-user')
  }
  stages {
    stage('Deploy') {
      steps {
        echo "Deploy to server"
        script {
          def remote = [:]
          remote.name = 'server'
          remote.host = 'server.company.com'
          remote.user = env.SERVER_CREDS_USR
          remote.password = env.SERVER_CREDS_PSW
          remote.allowAnyHosts = true
          sshScript(
            remote: remote,
            script: 'deploy.sh'
          )
        }
      }
    }
  }
}


If I have more than one line in the script deploy.sh, I do not get any output

It seems if I have multiple lines that produce output, then I do not get any output.
If I have multiple lines, and only the last command there has an output, then I get the output in the pipeline console output.

This works:
#!/bin/bash
DIR=/tmp
ls -ltr $DIR

This does not work:
#!/bin/bash
DIR=/tmp
ls -ltr $DIR
ls -ltr

Sverre Moe

unread,
Jan 19, 2022, 6:36:33 AM1/19/22
to Jenkins Users
This plugin has not been updated much the last 2-3 years.
https://github.com/jenkinsci/ssh-steps-plugin
I wonder if I should abandon it.

Reply all
Reply to author
Forward
0 new messages