-
Notifications
You must be signed in to change notification settings - Fork 10
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
/bin/sh: 5: source: not found #17
Comments
Good question. A couple of questions for clarification:
We can then figure something out how to better support the The second issue with the environment variables that are not present is less clear to me, perhaps if an exemplary script could show this as well would be helpful to write more. |
We're using ubuntu dockers as base images (but with bash as SHELL).
FROM ubuntu:latest
SHELL ["/bin/bash", "-c"]
image: ubuntu-bash
pipelines:
default:
- step:
name: Build and test
script:
- source /etc/os-release
- echo "$PRETTY_NAME" |
Thanks. Is the |
Yes, because the content of
(I put the wrong file to source in the example, copy past error. Fixed that now, so please modify in your trials as well) |
Please find a temporary topic branch I target release version 0.0.66 for the new bash runner feature. |
Thank you for taking the time to fix this! Unfortunately it still doesn't work for our full system. So I've put together a new example :/ FROM ubuntu:latest
RUN echo "HELLO=YOU" > ~/.bashrc
SHELL ["/bin/bash", "-c"] image: ubuntu-bash
pipelines:
default:
- step:
name: Build and test
script:
- echo "$HELLO"
- source /etc/os-release
- echo "$PRETTY_NAME" Now the outcome is the same as from the docker command: $ docker run ubuntu-bash echo "$HELLO"
<nothing> $ ~/Downloads/pipelines.phar
+++ step #1
name...........: "Build and test"
effective-image: ubuntu-bash
container......: pipelines-1.Build-and-test.default.test
container-id...: 7e400d87b793
+++ copying files into container...
+ echo "$HELLO"
+ source /etc/os-release
+ echo "$PRETTY_NAME"
Ubuntu 22.04 LTS However, inside the docker: $ docker run -it ubuntu-bash
root@10dc7d3e3e46:/# echo $HELLO
YOU So from within the docker all variables declared in the .bashrc file are present. Looks like the pipelines run inside the dockerfile. This might be a completely different concept than what this project is doing? |
Not sure I understand. From your feedback I read that you'd like to have the environment configured by You can also inspect what pipelines does by executing with |
pipelines is /bin/sh from the ground up. however some scripts need to run with /bin/bash. given /bin/bash in the container is an executable file, it is preferred over /bin/sh by default. Example pipeline with /bin/bash: $ bin/pipelines --pipeline custom/bash-runner --verbatim + source /etc/os-release + echo "$PRETTY_NAME" Ubuntu 22.04 LTS Example pipeline (previous behaviour): $ bin/pipelines -c script.bash-runner=false --pipeline custom/bash-runner --verbatim + source /etc/os-release /bin/sh: 5: source: not found script non-zero exit status: 127 report: #17
test for ~/.bashrc --- Looking into the bash runners' `~/.bashrc` issue. It now seems valid to me that, when using `/bin/bash` as script runner, to execute (source as in source - not dot - bashism) it if it exists at the very beginning of the step scripts. Rationale is the history of the Atlassian Bitbucket Pipelines Plugin. Before February 2017, scripts were run in an interactive shell. The Atlassian Bitbucket Pipelines Plugin continued _"to execute the .bashrc file as if run in an interactive non-login shell but it"_ then behaved _"as a non-interactive shell"_ ([ref]). shell: [interactive, non-login] | ~> # February 2017 [ref] ~> [non-interactive, non-login] + if [ -f ~/.bashrc ]; then . ~/.bashrc; fi # from: ref: GNU Bash: [Invoked as an interactive non-login shell] +' if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # source (bashism) asserts /bin/bash (over /bin/sh) +" test "$0" = "/bin/bash" && if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # test for bash runner (/bin/bash) report: #17 ref: GNU Bash: [Invoked as an interactive non-login shell] [ref]: https://confluence.atlassian.com/bbkb/infrastructure-changes-in-bitbucket-pipelines-1142431176.html#InfrastructurechangesinBitbucketPipelines-Scriptsarenolongerruninaninteractiveshell [Invoked as an interactive non-login shell]: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-as-an-interactive-non_002dlogin-shell
@Timple Did some tests for It now seems valid to me that, when using Rationale is the history of the Atlassian Bitbucket Pipelines Plugin. Before February 2017, scripts were run in an interactive shell. The Atlassian Bitbucket Pipelines Plugin continued "to execute the .bashrc file as if run in an interactive non-login shell but it" then behaved "as a non-interactive shell" (ref).
ref: GNU Bash: Invoked as an interactive non-login shell Please continue to find a temporary topic branch I continue to target release version 0.0.66 for the new bash runner feature. |
test for ~/.bashrc --- Looking into the bash runners' `~/.bashrc` issue. It now seems valid to me that, when using `/bin/bash` as script runner, to execute (source as in source - not dot - bashism) it if it exists at the very beginning of the step scripts. Rationale is the history of the Atlassian Bitbucket Pipelines Plugin. Before February 2017, scripts were run in an interactive shell. The Atlassian Bitbucket Pipelines Plugin continued _"to execute the .bashrc file as if run in an interactive non-login shell but it"_ then behaved _"as a non-interactive shell"_ ([ref]). shell: [interactive, non-login] | ~> # February 2017 [ref] ~> [non-interactive, non-login] + if [ -f ~/.bashrc ]; then . ~/.bashrc; fi # from: ref: GNU Bash: [Invoked as an interactive non-login shell] +' if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # source (bashism) asserts /bin/bash (over /bin/sh) +" test "$0" = "/bin/bash" && if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # test for bash runner (/bin/bash) report: #17 ref: GNU Bash: [Invoked as an interactive non-login shell] [ref]: https://confluence.atlassian.com/bbkb/infrastructure-changes-in-bitbucket-pipelines-1142431176.html#InfrastructurechangesinBitbucketPipelines-Scriptsarenolongerruninaninteractiveshell [Invoked as an interactive non-login shell]: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-as-an-interactive-non_002dlogin-shell
pipelines is /bin/sh from the ground up. however some scripts need to run with /bin/bash. given /bin/bash in the container is an executable file, it is preferred over /bin/sh by default. Example pipeline with /bin/bash: $ bin/pipelines --pipeline custom/bash-runner --verbatim + source /etc/os-release + echo "$PRETTY_NAME" Ubuntu 22.04 LTS Example pipeline (previous behaviour): $ bin/pipelines -c script.bash-runner=false --pipeline custom/bash-runner --verbatim + source /etc/os-release /bin/sh: 5: source: not found script non-zero exit status: 127 The bash runner /bin/bash additionally demands support to source .bashrc. Rationale is the history of the Atlassian Bitbucket Cloud Pipelines Plugin. Before February 2017, scripts were run in an interactive shell. The Atlassian Bitbucket Pipelines Plugin continued "to execute the .bashrc file as if run in an interactive non-login shell but it" then behaved "as a non-interactive shell" ([ref]). shell: [interactive, non-login] | ~> # February 2017 [ref] ~> [non-interactive, non-login] + if [ -f ~/.bashrc ]; then . ~/.bashrc; fi # from: ref: GNU Bash: [Invoked as an interactive non-login shell] +' if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # source (bashism) asserts /bin/bash (over /bin/sh) +" test "$0" = "/bin/bash" && if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # test for bash runner (/bin/bash) report: #17 ref: GNU Bash: [Invoked as an interactive non-login shell] [ref]: https://confluence.atlassian.com/bbkb/infrastructure-changes-in-bitbucket-pipelines-1142431176.html#InfrastructurechangesinBitbucketPipelines-Scriptsarenolongerruninaninteractiveshell [Invoked as an interactive non-login shell]: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-as-an-interactive-non_002dlogin-shell
@Timple if .bashrc is executed, would it then match all of your expectations? Because then I'd say from my end this ready and I'll prepare the next release. |
Awesome, this works! Thank you. One item left (unrelated so I'll open up a new issue! |
pipelines is /bin/sh from the ground up. however some scripts need to run with /bin/bash. given /bin/bash in the container is an executable file, it is preferred over /bin/sh by default. Example pipeline with /bin/bash: $ bin/pipelines --pipeline custom/bash-runner --verbatim + source /etc/os-release + echo "$PRETTY_NAME" Ubuntu 22.04 LTS Example pipeline (previous behaviour): $ bin/pipelines -c script.bash-runner=false --pipeline custom/bash-runner --verbatim + source /etc/os-release /bin/sh: 5: source: not found script non-zero exit status: 127 The bash runner /bin/bash additionally demands support to source .bashrc. Rationale is the history of the Atlassian Bitbucket Cloud Pipelines Plugin. Before February 2017, scripts were run in an interactive shell. The Atlassian Bitbucket Pipelines Plugin continued "to execute the .bashrc file as if run in an interactive non-login shell but it" then behaved "as a non-interactive shell" ([ref]). shell: [interactive, non-login] | ~> # February 2017 [ref] ~> [non-interactive, non-login] + if [ -f ~/.bashrc ]; then . ~/.bashrc; fi # from: ref: GNU Bash: [Invoked as an interactive non-login shell] +' if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # source (bashism) asserts /bin/bash (over /bin/sh) +" test "$0" = "/bin/bash" && if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # test for bash runner (/bin/bash) report: #17 ref: GNU Bash: [Invoked as an interactive non-login shell] [ref]: https://confluence.atlassian.com/bbkb/infrastructure-changes-in-bitbucket-pipelines-1142431176.html#InfrastructurechangesinBitbucketPipelines-Scriptsarenolongerruninaninteractiveshell [Invoked as an interactive non-login shell]: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-as-an-interactive-non_002dlogin-shell
pipelines is /bin/sh from the ground up. however some scripts need to run with /bin/bash. given /bin/bash in the container is an executable file, it is preferred over /bin/sh by default. Example pipeline with /bin/bash: $ bin/pipelines --pipeline custom/bash-runner --verbatim + source /etc/os-release + echo "$PRETTY_NAME" Ubuntu 22.04 LTS Example pipeline (previous behaviour): $ bin/pipelines -c script.bash-runner=false --pipeline custom/bash-runner --verbatim + source /etc/os-release /bin/sh: 5: source: not found script non-zero exit status: 127 The bash runner /bin/bash additionally demands support to source .bashrc. Rationale is the history of the Atlassian Bitbucket Cloud Pipelines Plugin. Before February 2017, scripts were run in an interactive shell. The Atlassian Bitbucket Pipelines Plugin continued "to execute the .bashrc file as if run in an interactive non-login shell but it" then behaved "as a non-interactive shell" ([ref]). shell: [interactive, non-login] | ~> # February 2017 [ref] ~> [non-interactive, non-login] + if [ -f ~/.bashrc ]; then . ~/.bashrc; fi # from: ref: GNU Bash: [Invoked as an interactive non-login shell] +' if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # source (bashism) asserts /bin/bash (over /bin/sh) +" test "$0" = "/bin/bash" && if [ -f ~/.bashrc ]; then source ~/.bashrc; fi # test for bash runner (/bin/bash) report: #17 ref: GNU Bash: [Invoked as an interactive non-login shell] [ref]: https://confluence.atlassian.com/bbkb/infrastructure-changes-in-bitbucket-pipelines-1142431176.html#InfrastructurechangesinBitbucketPipelines-Scriptsarenolongerruninaninteractiveshell [Invoked as an interactive non-login shell]: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html#Invoked-as-an-interactive-non_002dlogin-shell
Released in 0.0.66. |
I only now read this comment (was on phone yesterday). You did an awesome job investiging! |
Our images in the bitbucket-pipelines have bash as default runner. Can this be adhered?
This does not only affect the
source
command, which we could easily replace by.
. But also environment variables that should be present are not there.The text was updated successfully, but these errors were encountered: