cirrus-ci-docs
cirrus-ci-docs copied to clipboard
Add example on how to use `matrix` with env vars
took me too long to figure this out
Hmm, I also expected this to generate 4 tasks, but it generates 16:
blah_task:
name: Build
container:
image: alpine:3.20
env:
# Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800
matrix:
ANDROID_CLT_VERSION: 9123335 # v8, latest compatible with JDK 8+
JDK_PACKAGE: openjdk-8-jdk
matrix:
ANDROID_CLT_VERSION: 9862592 # v10, latest compatible with JDK 11+
JDK_PACKAGE: openjdk-11-jdk
matrix:
ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
JDK_PACKAGE: openjdk-17-jdk
matrix:
ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
JDK_PACKAGE: openjdk-21-jdk
info_script:
- echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_PACKAGE"
There's an easy workaround in this case though
workaround
blah_task:
name: Build
container:
image: alpine:3.20
env:
# Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800
matrix:
# v8, latest compatible with JDK 8+
ANDROID_AND_JDK: 9123335:openjdk-8-jdk
# v10, latest compatible with JDK 11+
ANDROID_AND_JDK: 9862592:openjdk-11-jdk
# v13, latest compatible with JDK 17+
ANDROID_AND_JDK: 11479570:openjdk-17-jdk
# v13, latest compatible with JDK 17+
ANDROID_AND_JDK: 11479570:openjdk-21-jdk
export_env_vars_script:
- export ANDROID_CLT_VERSION="$(echo $ANDROID_AND_JDK | cut -d ':' -f1)"
- export JDK_PACKAGE="$(echo $ANDROID_AND_JDK | cut -d ':' -f2)"
- echo "ANDROID_CLT_VERSION=$ANDROID_CLT_VERSION" >> $CIRRUS_ENV
- echo "JDK_PACKAGE=$JDK_PACKAGE" >> $CIRRUS_ENV
info_script:
- echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_PACKAGE"
Hmm, I also expected this to generate 4 tasks, but it generates 16
This should work:
blah_task:
name: Build
container:
image: alpine:3.20
env:
# Android Command-line tools were obtained with https://stackoverflow.com/a/78890086/7009800
matrix:
- ANDROID_CLT_VERSION: 9123335 # v8, latest compatible with JDK 8+
JDK_PACKAGE: openjdk-8-jdk
- ANDROID_CLT_VERSION: 9862592 # v10, latest compatible with JDK 11+
JDK_PACKAGE: openjdk-11-jdk
- ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
JDK_PACKAGE: openjdk-17-jdk
- ANDROID_CLT_VERSION: 11479570 # v13, latest compatible with JDK 17+
JDK_PACKAGE: openjdk-21-jdk
info_script:
- echo "Building Android SDK with Android Command-line tools $ANDROID_CLT_VERSION and JDK $JDK_PACKAGE"
Regarding the PR itself, perhaps it should use this syntax too.
I think the current way is better to generate 6 tasks - less duplication is involved.
I added another example to make it clear that matrix env vars can be also configured on a fine-grained level, just like you showed in https://github.com/cirruslabs/cirrus-ci-docs/pull/1288#issuecomment-2302111219
It seems that the "Spell Check" is failing because granularly is not present in .spelling.
Thanks, fixed.
btw, it seems that the tool used for spellchecking hasn't seen a commit to master in ~4 years, and the latest version is ~7 years old.