Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we use bash for custom workflow's run step? #2177

Closed
qingvincentyin opened this issue Apr 1, 2022 · 4 comments · Fixed by #3451
Closed

Can we use bash for custom workflow's run step? #2177

qingvincentyin opened this issue Apr 1, 2022 · 4 comments · Fixed by #3451

Comments

@qingvincentyin
Copy link

qingvincentyin commented Apr 1, 2022

It appears that the run step in a custom workflow is using the Bourne shell (/bin/sh) rather than bash.

Is there a way to tell custom workflow's run step to use bash?

(I suppose I can do /bin/bash -c ... as an indirection, but then I'd have to worry about escaping special characters, etc. It'll be a lot easier if I can just write in straight bash syntax.)


UPDATE 6 months later: Some workarounds...

Extend this base Docker image (therefore run our own custom image for Atlantis in Kubernetes). Copy our own bash custom shell script (say, /.../my_bash_script.sh) into the new image, or alternatively, mount a volume (containing my_bash_script.sh) to the image/pod. Then, from Atlantis run step, we could do /bin/bash /.../my_bash_script.sh
.

@bogdan-rizac
Copy link

@lkysow any answer on this ? At least an idea on how to switch to bash would be great

@nitrocode
Copy link
Member

nitrocode commented Nov 5, 2022

@qingvincentyin @bogdan-rizac

You folks can use any shell you like by cutting your own image and installing it.

RUN apk add bash

You can then run a script in a custom workflow and use a shebang like this

#!/usr/bin/env bash

@nitrocode
Copy link
Member

If you'd like to change the interpreter, someone could add a new flag that defaults to sh and passes the flag to each of these places.

https://github.com/search?q=repo%3Arunatlantis%2Fatlantis+exec.Command%28%22sh%22%2C&type=code&l=Go

Please feel free to contribute a new change.

The easier method would be to write a shell script, set the interpreter using the shebang, and run it using the run step.

@bml1g12
Copy link

bml1g12 commented May 4, 2023

If you'd like to change the interpreter, someone could add a new flag that defaults to sh and passes the flag to each of these places.

https://github.com/search?q=repo%3Arunatlantis%2Fatlantis+exec.Command%28%22sh%22%2C&type=code&l=Go

Please feel free to contribute a new change.

The easier method would be to write a shell script, set the interpreter using the shebang, and run it using the run step.

Sadly I don't think the "easier method" works:

with test.sh

#!/usr/bin/env bash
set -Eeuxo pipefail
set +o pipefail
set +x
echo $0
echo "hello"  |& tee -a test.log

cat test.sh | sh

03955a7d9e3a:/mount# cat test.sh | sh 
+ set +o pipefail
+ set +x
sh
sh: syntax error: unexpected "&"

Expected output:

03955a7d9e3a:/mount# cat test.sh | bash
+ set +o pipefail
+ set +x
bash
hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants