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