Skip to content

Commit 6c639f8

Browse files
Handle circleci command being missing in chrome install (#118)
This allows usage of the script in Dockerfiles where circleci is not installed. Note that none of the other install scripts reply on circleci. Example Dockerfile snippet: ``` # Install Chrome tools # Parameters taken from the source code of the ORB and https://circleci.com/developer/orbs/orb/circleci/browser-tools#commands-install-chromedriver ENV ORB_PARAM_CHANNEL=stable ENV ORB_PARAM_CHROME_VERSION=latest ENV ORB_PARAM_REPLACE_EXISTING=false RUN curl -sSL "https://raw.githubusercontent.com/CircleCI-Public/browser-tools-orb/main/src/scripts/install-chrome.sh" | bash ``` Co-authored-by: Mateo Arboleda <mateo.arboleda@circleci.com>
1 parent 2611bb1 commit 6c639f8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/scripts/install-chrome.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi
33

44
# process ORB_PARAM_CHROME_VERSION
5-
PROCESSED_CHROME_VERSION=$(circleci env subst "$ORB_PARAM_CHROME_VERSION")
5+
if command -v circleci &>/dev/null; then
6+
# CircleCI is installed, proceed with substitution
7+
PROCESSED_CHROME_VERSION=$(circleci env subst "$ORB_PARAM_CHROME_VERSION")
8+
else
9+
# CircleCI is not installed, fallback to using the environment variable as-is
10+
echo "CircleCI CLI is not installed. Relying on the environment variable ORB_PARAM_CHROME_VERSION to be set manually."
11+
PROCESSED_CHROME_VERSION=${ORB_PARAM_CHROME_VERSION:-latest} # Default to "latest" if the variable is unset
12+
fi
613

714
save_cache() {
815
echo "Saving cache"

0 commit comments

Comments
 (0)