Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example on how to use matrix with env vars #1288

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ gcp.community.nat.cirrus
git
go-git
gradle
granularly
hostname
i.e.
iOS
Expand Down
47 changes: 47 additions & 0 deletions docs/guide/writing-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,53 @@ The `matrix` modification makes it easy to create some pretty complex testing sc
test_script: yarn run test
```

Another example showing how to create 2 tasks with different environment
variables:

```yaml
task:
name: matrixdemo
container:
image: alpine:3.20
env:
matrix:
FIRST_VAR: foo
FIRST_VAR: bar
FIRST_VAR: baz
matrix:
SECOND_VAR: alpha
SECOND_VAR: bravo
print_script:
- echo "FIRST_VAR value is $FIRST_VAR"
- echo "SECOND_VAR value is $SECOND_VAR"
```

The above will generate 6 tasks.

And yet another example, showing how to granularly control the environment variables for each matrix:

```yaml
task:
name: matrixdemo
container:
image: ubuntu:24.04
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"
```

The above will generate 4 tasks.

## Task Execution Dependencies

Sometimes it might be very handy to execute some tasks only after successful execution of other tasks. For such cases
Expand Down