durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

judaondo
I am executing the following script: 

sh label: "<-- Zipping files -->", script: "cd ${JENKINS_HOME}/userContent/myfiles/; zip myzip.zip *; ls -alh; sleep 30s; rm !(myzip.zip)"

But I am getting the following error:

durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

I have also tried adding sheblang but it doesn´t work neither:

#!/bin/bash

Any workaround to fix this please?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c5970e0b-4edb-4624-b9fc-5baee2fcbc63%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

Victor Martinez
Double quotes might be a bit tricky with the interpolation and gstring.

I'd suggest move the script content to a file in your repo and just call the script using:

sh label:"<-- Zipping files -->", script: "your_script.sh"

I'd suggest to chmod 755 your_script.sh and add some shebang too.

The main benefit is the logic will be somewhere rather than in the Jenkinsfile/pipeline and, therefore it would be easy to test and run without any other requirements. Pipelines should just care of the orchestration.

Cheers

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/696632e9-add6-4c9d-9d21-9c6d6270402d%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

Daniel Beck-2
In reply to this post by judaondo
Assuming bash as the default shell, you did not call `shopt -s extglob`, so `!(pattern)` is unsupported.

Unrelated to Jenkins.

On Tue, Nov 26, 2019 at 2:48 PM judaondo <[hidden email]> wrote:
I am executing the following script: 

sh label: "<-- Zipping files -->", script: "cd ${JENKINS_HOME}/userContent/myfiles/; zip myzip.zip *; ls -alh; sleep 30s; rm !(myzip.zip)"

But I am getting the following error:

durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

I have also tried adding sheblang but it doesn´t work neither:

#!/bin/bash

Any workaround to fix this please?

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c5970e0b-4edb-4624-b9fc-5baee2fcbc63%40googlegroups.com.


--

Daniel Beck
Senior Software Engineer
CloudBees, Inc.

CloudBees-Logo.png


--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAMo7Pt%2B%3D0PjzvJ8S12wqN-pT%2BN62_E1aupyag0YfrLohkc%3DS_Q%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

judaondo
Hello Daniel, 

what do you mean by "shopt -s extglob" I don´t understand.

El miércoles, 27 de noviembre de 2019, 12:13:35 (UTC+1), Daniel Beck escribió:
Assuming bash as the default shell, you did not call `shopt -s extglob`, so `!(pattern)` is unsupported.

Unrelated to Jenkins.

On Tue, Nov 26, 2019 at 2:48 PM judaondo <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="S73ZNRDECQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jonu...@...> wrote:
I am executing the following script: 

sh label: "<-- Zipping files -->", script: "cd ${JENKINS_HOME}/userContent/myfiles/; zip myzip.zip *; ls -alh; sleep 30s; rm !(myzip.zip)"

But I am getting the following error:

durable-dbed1d4d/script.sh: Syntax error: "(" unexpected

I have also tried adding sheblang but it doesn´t work neither:

#!/bin/bash

Any workaround to fix this please?

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="S73ZNRDECQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/c5970e0b-4edb-4624-b9fc-5baee2fcbc63%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/c5970e0b-4edb-4624-b9fc-5baee2fcbc63%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/c5970e0b-4edb-4624-b9fc-5baee2fcbc63%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/c5970e0b-4edb-4624-b9fc-5baee2fcbc63%40googlegroups.com.


--

Daniel Beck
Senior Software Engineer
CloudBees, Inc.

CloudBees-Logo.png


--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d15649e8-59de-4860-9bbc-a02111f78bcd%40googlegroups.com.