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

Global environment variables are not merged with matrix includes #6703

Closed
raphaelstolt opened this Issue Oct 10, 2016 · 10 comments

Comments

Projects
None yet
2 participants
@raphaelstolt

raphaelstolt commented Oct 10, 2016

This might be a bug or a misconfiguration on my end.

Assumed I if have the following configuration:

env:
  global:
    - excludegroup=travis-ci-exclude
    - disable-xdebug=true
    - lint=false

matrix:
  include:
    - php: hhvm
      env: disable-xdebug=false
    - php: nightly
      env: disable-xdebug=false
    - php: 7.1
      env: disable-xdebug=false lint=true
    - php: 7.0
    - php: 5.6
      env: excludegroup=travis-ci-exclude-56

On the build jobs I would expect the following environment variables set:

hhvm: excludegroup=travis-ci-exclude disable-xdebug=false lint=false
nightly: excludegroup=travis-ci-exclude disable-xdebug=false lint=false
7.1: excludegroup=travis-ci-exclude disable-xdebug=false lint=true
7.0: excludegroup=travis-ci-exclude disable-xdebug=true lint=false
5.6: excludegroup=travis-ci-exclude-56 disable-xdebug=true lint=false

But it seems like the global enviroment variables are not merged with the ones set in the matrix include so that I end up with the following environment variables set:

hhvm: disable-xdebug=false
nightly: disable-xdebug=false
7.1: disable-xdebug=false lint=true
7.0: 
5.6: excludegroup=travis-ci-exclude-56
@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 10, 2016

Member

Do you have a build log URL that shows the problem you are describing here?

I tested

env:
  global:
    - excludegroup=travis-ci-exclude
    - disable-xdebug=true
    - lint=false

matrix:
  include:
    - php: hhvm
      env: disable-xdebug=false
    - php: nightly
      env: disable-xdebug=false
    - php: 7.1
      env: disable-xdebug=false lint=true
    - php: 7.0
    - php: 5.6
      env: excludegroup=travis-ci-exclude-56

(https://github.com/BanzaiMan/travis_production_test/blob/b1ddff8d948e24b602f7e8a9b55178e81c111c96/.travis.yml) and got what you expect. https://travis-ci.org/BanzaiMan/travis_production_test/builds/166555701

Member

BanzaiMan commented Oct 10, 2016

Do you have a build log URL that shows the problem you are describing here?

I tested

env:
  global:
    - excludegroup=travis-ci-exclude
    - disable-xdebug=true
    - lint=false

matrix:
  include:
    - php: hhvm
      env: disable-xdebug=false
    - php: nightly
      env: disable-xdebug=false
    - php: 7.1
      env: disable-xdebug=false lint=true
    - php: 7.0
    - php: 5.6
      env: excludegroup=travis-ci-exclude-56

(https://github.com/BanzaiMan/travis_production_test/blob/b1ddff8d948e24b602f7e8a9b55178e81c111c96/.travis.yml) and got what you expect. https://travis-ci.org/BanzaiMan/travis_production_test/builds/166555701

@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 10, 2016

Member

Oh. Did you mean you wanted environment variables whose names contain -?

Member

BanzaiMan commented Oct 10, 2016

Oh. Did you mean you wanted environment variables whose names contain -?

@raphaelstolt

This comment has been minimized.

Show comment
Hide comment
@raphaelstolt

raphaelstolt Oct 10, 2016

Nope I want the environment variables defined as global to be merged with the ones set in the matrix.

And a build where that doesn't happen would be https://travis-ci.org/raphaelstolt/lean-package-validator/builds/166436492 and the relevant .travis.yml would be https://github.com/raphaelstolt/lean-package-validator/blob/109bc0da6302c55689fd0ad27da1711cdd09d3e0/.travis.yml.

If you look at the build job for PHP 7 there are no environment variables set at all and I would expect the ones shown next, as they were set globally.

excludegroup=travis-ci-exclude disable-xdebug=true lint=false

raphaelstolt commented Oct 10, 2016

Nope I want the environment variables defined as global to be merged with the ones set in the matrix.

And a build where that doesn't happen would be https://travis-ci.org/raphaelstolt/lean-package-validator/builds/166436492 and the relevant .travis.yml would be https://github.com/raphaelstolt/lean-package-validator/blob/109bc0da6302c55689fd0ad27da1711cdd09d3e0/.travis.yml.

If you look at the build job for PHP 7 there are no environment variables set at all and I would expect the ones shown next, as they were set globally.

excludegroup=travis-ci-exclude disable-xdebug=true lint=false
@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 11, 2016

Member

- is an illegal character in bash environment variables, and it doesn't work. In https://travis-ci.org/raphaelstolt/lean-package-validator/jobs/166436499#L127-L130, you see that we set 2 of the environment variables defined in https://github.com/raphaelstolt/lean-package-validator/blob/109bc0da6302c55689fd0ad27da1711cdd09d3e0/.travis.yml#L3-L7:

$ export excludegroup=travis-ci-exclude
$ export xdebug=true
$ export lint=false

Notice that we are exporting xdebug=true, because characters up to (and including) the last illegal character (- in this case) is implicitly dropped. (This might be misleading, actually. Perhaps we should be more explicit about this.)

The other two are exported.

Member

BanzaiMan commented Oct 11, 2016

- is an illegal character in bash environment variables, and it doesn't work. In https://travis-ci.org/raphaelstolt/lean-package-validator/jobs/166436499#L127-L130, you see that we set 2 of the environment variables defined in https://github.com/raphaelstolt/lean-package-validator/blob/109bc0da6302c55689fd0ad27da1711cdd09d3e0/.travis.yml#L3-L7:

$ export excludegroup=travis-ci-exclude
$ export xdebug=true
$ export lint=false

Notice that we are exporting xdebug=true, because characters up to (and including) the last illegal character (- in this case) is implicitly dropped. (This might be misleading, actually. Perhaps we should be more explicit about this.)

The other two are exported.

@raphaelstolt

This comment has been minimized.

Show comment
Hide comment
@raphaelstolt

raphaelstolt Oct 11, 2016

Okay didn't know that - is an illegal character in an bash environment variable. Should I create an issue that Travis lint should warn about this?

Fixed it with b279e and the global set envirionment variables are still lost. You can see it at PHP 7 where the environment variables should be $EXCLUDEGROUP=travis-ci-exclude $DISABLE_XDEBUG=true $LINT=false but Travis CI says no environment variables set.

Or is the global defintion faulty?

env:
  global:
    - EXCLUDEGROUP=travis-ci-exclude
    - DISABLE_XDEBUG=true
    - LINT=false

raphaelstolt commented Oct 11, 2016

Okay didn't know that - is an illegal character in an bash environment variable. Should I create an issue that Travis lint should warn about this?

Fixed it with b279e and the global set envirionment variables are still lost. You can see it at PHP 7 where the environment variables should be $EXCLUDEGROUP=travis-ci-exclude $DISABLE_XDEBUG=true $LINT=false but Travis CI says no environment variables set.

Or is the global defintion faulty?

env:
  global:
    - EXCLUDEGROUP=travis-ci-exclude
    - DISABLE_XDEBUG=true
    - LINT=false
@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 11, 2016

Member

The build page (e.g., https://travis-ci.org/raphaelstolt/lean-package-validator/builds/166636690) does not show the environment variables that are set globally, since they are not defining characteristics of the jobs.

They are set just fine. https://travis-ci.org/raphaelstolt/lean-package-validator/jobs/166636694#L127-L130

I don't think there is a bug here. We should deal with illegal characters, but that should be a separate issue.

Member

BanzaiMan commented Oct 11, 2016

The build page (e.g., https://travis-ci.org/raphaelstolt/lean-package-validator/builds/166636690) does not show the environment variables that are set globally, since they are not defining characteristics of the jobs.

They are set just fine. https://travis-ci.org/raphaelstolt/lean-package-validator/jobs/166636694#L127-L130

I don't think there is a bug here. We should deal with illegal characters, but that should be a separate issue.

@raphaelstolt

This comment has been minimized.

Show comment
Hide comment
@raphaelstolt

raphaelstolt Oct 11, 2016

So how does one set an environment variable available on all php versions?

Something that avoids the duplication of OPCODE_CACHE shown next.

matrix:
  include:
    - php: hhvm
      env:
      - OPCODE_CACHE=apc
    - php: nightly
      env:
      - OPCODE_CACHE=apc
    - php: 7.1
      env:
      - OPCODE_CACHE=apc
    - php: 7.0
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
      - LINT=true
    - php: 5.6
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
    - php: 5.5
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
    - php: 5.4
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
    - php: 5.3
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true

This one is close, with a weird side effect of adding a undefined PHP version and also not merging both variable definitions.

The global environement variable FOO is set via:

env:
  FOO=bar

raphaelstolt commented Oct 11, 2016

So how does one set an environment variable available on all php versions?

Something that avoids the duplication of OPCODE_CACHE shown next.

matrix:
  include:
    - php: hhvm
      env:
      - OPCODE_CACHE=apc
    - php: nightly
      env:
      - OPCODE_CACHE=apc
    - php: 7.1
      env:
      - OPCODE_CACHE=apc
    - php: 7.0
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
      - LINT=true
    - php: 5.6
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
    - php: 5.5
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
    - php: 5.4
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true
    - php: 5.3
      env:
      - OPCODE_CACHE=apc
      - DISABLE_XDEBUG=true

This one is close, with a weird side effect of adding a undefined PHP version and also not merging both variable definitions.

The global environement variable FOO is set via:

env:
  FOO=bar
@BanzaiMan

This comment has been minimized.

Show comment
Hide comment
@BanzaiMan

BanzaiMan Oct 11, 2016

Member

Common variables should go into env.global. These don't show up in the build page, but they are defined and exported. Please read your logs carefully.

Member

BanzaiMan commented Oct 11, 2016

Common variables should go into env.global. These don't show up in the build page, but they are defined and exported. Please read your logs carefully.

@raphaelstolt

This comment has been minimized.

Show comment
Hide comment
@raphaelstolt

raphaelstolt Oct 11, 2016

Ah okay, expected them also to be present in the <div class="job-env"> in the build web user interface.

web-ui

raphaelstolt commented Oct 11, 2016

Ah okay, expected them also to be present in the <div class="job-env"> in the build web user interface.

web-ui

@raphaelstolt

This comment has been minimized.

Show comment
Hide comment
@raphaelstolt

raphaelstolt Oct 11, 2016

Created an issue #6707 for dealing with invalid environment variable names.

raphaelstolt commented Oct 11, 2016

Created an issue #6707 for dealing with invalid environment variable names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment