Skip to content

Commit 9fac113

Browse files
committed
fix: nifty env var workaround
1 parent ba53cbd commit 9fac113

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

.circleci/build-cli.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#! /bin/bash
22

3-
echo "Cloning CLI repo"
3+
echo "Starting CLI build process"
44
cd ~
55
# If the CLI repo doesn't exist (due to caching), clone it
6-
if [ ! -d "~/cli" ]; then
6+
if [ ! -d "cli" ]; then
77
echo "Cloning CLI repo"
88
git clone https://github.com/snyk/cli.git
99
else

.circleci/config.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,21 @@ jobs:
204204
command: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ../.npmrc
205205
- run:
206206
name: Get latest CLI commit hash
207+
# We can't use the CLI_COMMIT_HASH environment variable directly
208+
# But we can write it to a file and use that to restore the cache
207209
command: |
208210
CLI_COMMIT_HASH=$(git ls-remote https://github.com/snyk/cli.git main | cut -f1)
209-
echo "export CLI_COMMIT_HASH=$CLI_COMMIT_HASH" >> $BASH_ENV
210-
source $BASH_ENV
211+
echo "CLI_COMMIT_HASH: $CLI_COMMIT_HASH"
212+
echo $CLI_COMMIT_HASH >> /tmp/cli-version
211213
- restore_cache:
212214
keys:
213-
- v1-cli-repo-{{ .Environment.CLI_COMMIT_HASH }}
215+
- v1-cli-repo-{{ checksum "/tmp/cli-version" }}
214216
- v1-cli-repo-
215217
- run:
216218
name: Build Snyk CLI with latest changes
217219
command: ./.circleci/build-cli.sh
218220
- save_cache:
219-
key: v1-cli-repo-{{ .Environment.CLI_COMMIT_HASH }}
221+
key: v1-cli-repo-{{ checksum "/tmp/cli-version" }}
220222
paths:
221223
- ~/cli
222224
build_and_test_latest_go_binary:

0 commit comments

Comments
 (0)