Dynamic environment variables, before conditionals are evaluated

I wish to integrate Zenhub tagging into our pipeline, by running the travis pipeine only if the PR has a zenhub tag attached to it.

I wish to exclude running various stages unless an environment variable is set

jobs:
  include:
    - stage: test
      if: env(ZENHUB_PR_TAG)="PR:READY"
      name: 'Build + Lint + Unit Tests'

The problem is, this ZENHUB_PR_TAG variable is dynamic, and needs to be set by hitting the Zenhub API.

Is there anyway I can run a script to initialise my environment variables before running any of the jobs?

I’ve tried adding a before_install step outside the job matrix

before_install:
  - source ./travis/zenhub.sh # This sets ZENHUB_PR_TAG
jobs:
  include:
    - stage: test
      if: env(ZENHUB_PR_TAG)="PR:READY"
      name: 'Build + Lint + Unit Tests'

But my build is not run,

The only way I can get this job to run , is to hardcode

env:
 - ZENHUB_PR_TAG="PR:READY"

Hello, there. This is simply impossible.

We need to make a decision on whether or not to include a job before the VM is started, but the values concerned here must have a running VM in order to have the correct values.

One way you might be able to achieve what you want is to trigger a new API build when ZENHUB_PR_TAG has a desired value.

Imprint