Skip to content

Commit

Permalink
RS-353: Use /bin/real-bash in bash-wrapper to enable updating bats …
Browse files Browse the repository at this point in the history
…to v1.5.0 (#96)

* X-Smart-Branch-Parent: master
* Use real-bash in bash-wrapper. Update bats to v1.5.0
* Simplify cci-export
  • Loading branch information
vikin91 authored Dec 15, 2021
1 parent 6f084e9 commit 59b9b8d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 44 deletions.
1 change: 0 additions & 1 deletion images/Dockerfile.collector
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends lsb-release cma
ENV ROX_CI_IMAGE=collector-ci-image

COPY ./static-contents/bin/bash-wrapper /bin/
COPY ./static-contents/etc/bash.env /etc/

RUN \
mv /bin/bash /bin/real-bash && \
Expand Down
2 changes: 1 addition & 1 deletion images/Dockerfile.rox
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ RUN set -ex \

# Install bats
RUN set -ex \
&& npm install -g bats@1.2.0 [email protected] [email protected] [email protected] \
&& npm install -g bats@1.5.0 [email protected] [email protected] [email protected] \
&& bats -v

# Install jq
Expand Down
31 changes: 24 additions & 7 deletions images/static-contents/bin/bash-wrapper
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
#!/bin/sh
#!/bin/real-bash
# shellcheck shell=bash

# The second check is necessary because, in subshells of the parent shell,
# we want to ensure that the original REAL_BASH_ENV is not clobbered.
if [ -n "${BASH_ENV:-}" ] && [ "${BASH_ENV}" != "/etc/bash.env" ]; then
export REAL_BASH_ENV="${BASH_ENV}"
fi
# cci-export is a function which can be used to export environment variables in a way that is persistent
# across CircleCI steps.
cci-export() {
if [ "$#" -ne 2 ]; then
echo >&2 "Usage: $0 KEY VALUE"
return 1
fi

export BASH_ENV="/etc/bash.env"
key="$1"
value="$2"

export "${key}=${value}"

if [[ "$CIRCLECI" == "true" ]]; then
if [[ -z "${BASH_ENV}" ]]; then
echo >&2 "Env var BASH_ENV not properly set"
return 1
fi
echo "export ${key}=$(printf '%q' "$value")" >> "$BASH_ENV"
fi
}

export -f cci-export

exec /bin/real-bash "$@"
35 changes: 0 additions & 35 deletions images/static-contents/etc/bash.env

This file was deleted.

0 comments on commit 59b9b8d

Please sign in to comment.