The shell is parsing the script and found an error in the syntax, it's not
sh that is checking syntax. You can add a shebang line if you have
something specific to bash

sh """#!/bin/bash
rm -fr -v !(${name})"""

The sh step just creates a shell script file (.sh file) and executes it,
which would use the default shell. If that is not bash, then adding the
shebang will cause the script to be executed under bash.

Regards,

Alex

On Tue, Jun 30, 2020 at 9:28 AM Jérôme Godbout <godbo...@amotus.ca> wrote:

> Hi,
>
> I’m trying to run the following command:
>
>
>
> String name = ‘”download”’;
>
> sh(script: "rm -fr -v !(${name})");
>
>
>
> this results into the following string:
>
> *rm -fr -v !(“download”)*
>
>
>
> This run just fine into bash shell, I also tried with
>
> */bin/bash rm -fr -v !(“download”)*
>
> But I always  end up with:
>
> script.sh: Syntax error: "(" unexpected
>
>
>
> What the hell is sh is doing? I can understand the bash is required but
> why is he trying to parse the command before running it?
>
>
>
> Thanks,
>
> Jerome
>
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/YQBPR0101MB107495F3847A77E4B8A95B27CD6F0%40YQBPR0101MB1074.CANPRD01.PROD.OUTLOOK.COM
> <https://groups.google.com/d/msgid/jenkinsci-users/YQBPR0101MB107495F3847A77E4B8A95B27CD6F0%40YQBPR0101MB1074.CANPRD01.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>
> .
>


-- 
Website: http://earl-of-code.com

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVf2AXwoQUW8sx07gZJfowt8jhOjPO9P%3DA1EkiwVp-L%3D_w%40mail.gmail.com.

Reply via email to