0

I have done a lot of investigating trying to find examples of running shell() script commands in a preBuildSteps of a mavenJob. All I have found provides simple examples. For example:

mavenJob('example-1') {
    preBuildSteps {
        shell("echo 'run before Maven'")
    }
}

I would like to execute a linux bash script. for example:

shell("bash /scripts/pom.xml.exists.sh")

When I execute, I am receiving the following error message:

  • bash /scripts/pom.xml.exists.sh bash: /scripts/pom.xml.exists.sh: No such file or directory

Can someone let me know what I am doing wrong? Conversely, maybe a shell command that will tell me what directory I am supposedly in. Perhaps that will let me know why I get the not found message.

thanks

1 Answers1

1

try

shell("bash scripts/pom.xml.exists.sh")

or even

shell("scripts/pom.xml.exists.sh")

Looks like you're using absolute path by accident, but you want relative path.

bjamin
  • 131
  • 1
  • 5
  • thanks for your reply. I just tried this. it did not work. same error. I guess part of what I think I need to determine is where I am when trying to execute. How can I determine the directory structure? – Paul H. Jun 15 '17 at 11:59
  • pwd is the shell built-in command that will give you the Present Working Directory – Rob Kielty Jun 15 '17 at 20:33
  • I have been trying pwd but I do not get any output when I try it. here is an example of the syntax I have been trying. I have tried a few combinations. That is part of what I am asking. What is the syntax for commands like pwd? shell("bash pwd".execute().text) – Paul H. Jun 16 '17 at 11:38
  • you're overthinking it. just do 'shell("pwd")` – bjamin Jun 16 '17 at 21:53