• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • ssh-steps-plugin
    • None

      Calling sshCommand forces the allocation of PTY, however running commands on servers where there is no proper PTY support (win32-openssh) can generate failures such as garbage output, ...

      Being able to disable/enable PTY allocation would help for these environments

      EDIT: 

      There is PTY setting at the remote level, but actually not sure why I had to make it true at the command level, I think it needs to be defaulted false as there is no impact for LINUX boxes either way, I have tested it. Made a PR.

      And this PTY is also applicable for other steps, so instead it is good to have it at the remote level.
       

          [JENKINS-56989] Default pty to false for sshCommand

          I performed a pull request to handle this issue

          Jesús Malo Poyatos added a comment - I performed a pull request to handle this issue

          Naresh Rayapati added a comment - Follow up PR: https://github.com/jenkinsci/ssh-steps-plugin/pull/19

          Naresh Rayapati added a comment - Released with https://github.com/jenkinsci/ssh-steps-plugin/releases/tag/ssh-steps-2.0.0

          Erik-Jan Rieksen added a comment - - edited

          As noted in release notes "sudo: true" param also requires "pty: true". This change unfortunately broke my pipeline. Why not automatically set pty: true when sudo: true for backwards compatability?

          Erik-Jan Rieksen added a comment - - edited As noted in release notes "sudo: true" param also requires "pty: true". This change unfortunately broke my pipeline. Why not automatically set pty: true when sudo: true for backwards compatability?

          darthmineboy Can you post a bit of your pipeline code?, pty: true is only required for few of the platforms/ssh-agents like SSH on Linux.

          Note: pty: true is not an option for sshCommand but for the actual remote.

          Naresh Rayapati added a comment - darthmineboy Can you post a bit of your pipeline code?, pty: true is only required for few of the platforms/ssh-agents like SSH on Linux. Note: pty: true is not an option for sshCommand but for the actual remote.

          nrayapati with "remote.pty: true" added the build works as expected. Without pty true (after the latest plugin update) the build times out after 10 minutes (as configured) at sshCommand. Both the jenkins server and the SSH server to which is connected run Ubuntu. 

          def remote = [:]
          remote.name = 'ommitted'
          remote.host = 'ommitted'
          remote.user = 'ommitted'
          remote.password = 'ommitted'
          remote.allowAnyHosts = truepipeline {
           agent any
           options {
             timeout(time: 10)
             disableConcurrentBuilds()
           }
           stages {   stage('Clone repository') {
               steps {
                 checkout scm
               }
             }   stage('Build') {
               when {
                 anyOf {
                   branch 'development'
                   branch 'master'
                 }
               }
               steps {
                 echo 'Testing & Building...'
                 sh 'mvn -B clean package'
               }
             }   stage('Build docker image') {
               when {
                 anyOf {
                   branch 'development'
                   branch 'master'
                 }
               }     steps {
                 echo 'Building docker image...'
                 sh 'docker login -u ommitted'
                 sh 'docker build -t="ommitted" .'
               }
             }   stage('Push docker image') {
               when {
                 anyOf {
                   branch 'development'
                   branch 'master'
                 }
               }     steps {
                 echo 'Pushing docker image...'
                 sh 'docker push ommitted'
               }
             }   stage('Deploy') {
               when {
                 anyOf {
                   branch 'development'
                   branch 'master'
                 }
               }
               steps {
                 echo 'Deploying...'
                 sshCommand remote: remote, sudo: true, command: "sudo sh update.sh"
               }
             }
           }
          }
          

          Jenkins log

          Executing command on ommitted[ommitted]: sudo sh update.sh sudo: true
          Cancelling nested steps due to timeout
          d997b761-0e4a-4707-a205-d71cc489b9bc
          

          Erik-Jan Rieksen added a comment - nrayapati with "remote.pty: true" added the build works as expected. Without pty true (after the latest plugin update) the build times out after 10 minutes (as configured) at sshCommand. Both the jenkins server and the SSH server to which is connected run Ubuntu.  def remote = [:] remote.name = 'ommitted' remote.host = 'ommitted' remote.user = 'ommitted' remote.password = 'ommitted' remote.allowAnyHosts = truepipeline { agent any options { timeout(time: 10) disableConcurrentBuilds() } stages { stage( 'Clone repository' ) { steps { checkout scm } } stage( 'Build' ) { when { anyOf { branch 'development' branch 'master' } } steps { echo 'Testing & Building...' sh 'mvn -B clean package ' } } stage( 'Build docker image' ) { when { anyOf { branch 'development' branch 'master' } } steps { echo 'Building docker image...' sh 'docker login -u ommitted' sh 'docker build -t= "ommitted" .' } } stage( 'Push docker image' ) { when { anyOf { branch 'development' branch 'master' } } steps { echo 'Pushing docker image...' sh 'docker push ommitted' } } stage( 'Deploy' ) { when { anyOf { branch 'development' branch 'master' } } steps { echo 'Deploying...' sshCommand remote: remote, sudo: true , command: "sudo sh update.sh" } } } } Jenkins log Executing command on ommitted[ommitted]: sudo sh update.sh sudo: true Cancelling nested steps due to timeout d997b761-0e4a-4707-a205-d71cc489b9bc

          darthmineboy Awesome! thanks for the confirmation.

          Naresh Rayapati added a comment - darthmineboy Awesome! thanks for the confirmation.

            nrayapati Naresh Rayapati
            jmalopoy Jesús Malo Poyatos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: