0

I have a user interactive shell script that runs successfully on my Linux server. But when I try to run it via jenkins, it doesn't run.

I have created a Jenkinsfile.

Jenkinsfile

node('slaves')  {
      try
      {
    def app

stage('Remmove Docker service') {

        sh 'sshpass ssh docusr@10.26.13.12 "/path/to/shell/script"'

    }
}
}

Shell Script

#!/bin/bash
read -p "Hi kindly enter the api name : " api
docker service logs $api --raw

The shell Scipt runs successfully on my local server, when I try to run it on Jenkins using Jenkinsfile, it doesn't accept $api variable in my shell script which is user interactive.

susenj
  • 342
  • 1
  • 4
  • 12
Vicky
  • 63
  • 1
  • 1
  • 5

1 Answers1

0

What you are trying to achieve doesn't serve any purpose of automating your job by jenkins, if I correctly understood. So, your job is actually seeking a user input and it's in best interest to have a parameterized jenkins build in this case. For your case, you can still give an argument to the sshpass command $api and have it read from the jenkins environment itself Or, better make your jenkins build parameterized and use your user input $api as the parameter.

susenj
  • 342
  • 1
  • 4
  • 12