Discussion:
running shell commands in pipeline fails on pushd and source
'Carsten' via Jenkins Users
2018-12-07 13:34:37 UTC
Permalink
Hi list,

in a jenkinsfile I trigger a bash script like so:
"...
myresult=sh(script: 'deploy.sh', returnStdout: true)
..."
the script starts but returns errors like these:

"command not found: pushd"
"command not found: source"

And for some reasons it is not able to do such things:
"...
targetmachine=(
'host1'
'host2'
'host3'
)
..."

it replies: Syntax error: "(" unexpected.

Other commands like "if", "for", "echo", a.s.o are working.

The script itself is tested on the machine, where jenkins is running, and
it works.
Jenkins is installed as docker image "docker pull jenkins:jenkins".
The Image is started as "root" using "sudo docker run...."
Does anybody have an idea why these commands and the array creation fails?

br
Carsten
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a2181b6e-96cc-4182-abca-a8ae0a0e195f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Waite
2018-12-07 14:52:26 UTC
Permalink
That seems to hint that the shell invoked on that agent by the Pipeline
script is not compatible with the shell syntax you're using.

For example, is the shell on that agent inadvertently configured to be
'dash' instead of 'bash'? Is it configured to be 'csh' instead of 'bash'?

https://askubuntu.com/questions/590899/how-to-check-which-shell-am-i-using
suggests that you might run a test job with an sh 'echo $0' or with sh
'echo $SHELL'

On Fri, Dec 7, 2018 at 6:36 AM 'Carsten' via Jenkins Users <
Post by 'Carsten' via Jenkins Users
Hi list,
"...
myresult=sh(script: 'deploy.sh', returnStdout: true)
..."
"command not found: pushd"
"command not found: source"
"...
targetmachine=(
'host1'
'host2'
'host3'
)
..."
it replies: Syntax error: "(" unexpected.
Other commands like "if", "for", "echo", a.s.o are working.
The script itself is tested on the machine, where jenkins is running, and
it works.
Jenkins is installed as docker image "docker pull jenkins:jenkins".
The Image is started as "root" using "sudo docker run...."
Does anybody have an idea why these commands and the array creation fails?
br
Carsten
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/a2181b6e-96cc-4182-abca-a8ae0a0e195f%40googlegroups.com
<https://groups.google.com/d/msgid/jenkinsci-users/a2181b6e-96cc-4182-abca-a8ae0a0e195f%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
Thanks!
Mark Waite
--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHQqX0r5Ew_bJL%3D7b%3DjfMxwsxwX19Lf0xkR4PRjbeEV%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...