-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
13 changed files
with
156 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
# this file is part of pipelines | ||
# | ||
# pipelines:ubuntu-bash docker image | ||
# | ||
# usage: ./ubuntu-bash.sh [<docker-cmd>] | ||
# | ||
# <docker-cmd> "docker" by default | ||
# | ||
# requirements: docker (or equivalent) | ||
# | ||
# rationale: | ||
# | ||
# bitbucket pipelines runs the scripts with /bin/bash if available, so | ||
# a user asked for it and we need it to integrate with bash. | ||
# | ||
# <https://github.com/ktomk/pipelines/issues/17#issuecomment-1161612881> | ||
# | ||
set -euo pipefail | ||
IFS=$' \n\t' | ||
|
||
docker_cmd="${1-docker}" | ||
from="docker.io/ubuntu" | ||
tag="docker.io/ktomk/pipelines:ubuntu-bash" | ||
|
||
echo "build '${tag}' from '${from}' with ${docker_cmd}..." | ||
|
||
<<'DOCKERFILE' "${docker_cmd}" build --build-arg FROM="${from}" -t "${tag}" - | sed -e 's/^/ build: /' | ||
ARG FROM | ||
FROM $FROM | ||
RUN echo "HELLO=YOU" > ~/.bashrc | ||
SHELL ["/bin/bash", "-c"] | ||
DOCKERFILE | ||
|
||
echo "test '${tag}' ..." | ||
|
||
# shellcheck disable=SC2016 | ||
"${docker_cmd}" run --rm "${tag}" /bin/bash -c ' | ||
set -x | ||
echo "\$HELLO.......: $HELLO" | ||
echo "\$SHELL.......: $SHELL" | ||
echo "\$BASH_VERSION: $BASH_VERSION" | ||
/bin/bash --version | ||
which bash | ||
ls -lhi "$(which bash)" | ||
ls -lhi /bin/bash | ||
source /etc/os-release | ||
echo "$PRETTY_NAME" | ||
' 2>&1 | sed -e 's/^/ test.: /' | ||
|
||
echo "push '${tag}' ..." | ||
|
||
"${docker_cmd}" push "${tag}" | sed -e 's/^/ push.: /' | ||
|
||
echo "done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.