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

Matrix variable not usable in environment #1945

Closed
5 tasks done
simmstein opened this issue Jul 7, 2023 · 5 comments
Closed
5 tasks done

Matrix variable not usable in environment #1945

simmstein opened this issue Jul 7, 2023 · 5 comments
Labels
enhancement improve existing features server

Comments

@simmstein
Copy link
Contributor

simmstein commented Jul 7, 2023

Component

server, agent

Describe the bug

When a variable is defined through a matrix, it's not possible to use it as environment variable.

This following configuration results on error: failed to parse pipeline: Cannot unmarshal '<nil>' of type <nil> into a string value.

matrix:
 FOO:
   - foo1
   - foo2

steps:
 example:
   image: alpine:latest
   environment:
     BAR: ${FOO}
   commands:
     - echo ${FOO}

But this following config works:

matrix:
  FOO:
    - foo1
    - foo2

steps:
  example:
    image: alpine:latest
    commands:
      - echo ${FOO}

System Info

{"source":"https://github.com/woodpecker-ci/woodpecker","version":"next-0cf602a1"}

Additional context

Example: https://ci.gitnet.fr/repos/315

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Checked that the bug isn't fixed in the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Check that this is a concrete bug. For Q&A join our Discord Chat Server or the Matrix room.
@simmstein simmstein added the bug Something isn't working label Jul 7, 2023
@6543 6543 added enhancement improve existing features server and removed bug Something isn't working labels Jul 7, 2023
@6543 6543 added this to the 1.1.0 milestone Jul 7, 2023
@pat-s
Copy link
Contributor

pat-s commented Oct 13, 2023

This seems to be the same issue as reported in #2505 (comment)

@pat-s pat-s modified the milestones: 2.0.0, 2.x.x Oct 13, 2023
@zc-devs
Copy link
Contributor

zc-devs commented Oct 16, 2023

matrix:
  FOO:
    - foo1
    - foo2

steps:
  example:
    image: alpine
    environment:
      BAR: ${FOO}
    commands:
      - echo foo=${FOO}
      - printenv

Can't reproduce on a95f1bc:
Screenshot 2023-10-16 185337

Also, it's not necessary to pass matrix variable via environment, as it is available by its name:
Screenshot 2023-10-16 185451

@simmstein
Copy link
Contributor Author

Yes it works: https://ci.gitnet.fr/repos/315/pipeline/4

But, using matrix this ways failed:

matrix:
  PHP_VERSION:
    - 8.1
    - 8.2

steps:
  example:
    image: deblan/php:${PHP_VERSION}
    commands:
      - php -v
matrix:
  PHP_VERSION:
    - 8.1
    - 8.2

steps:
  example:
    image: deblan/php:$PHP_VERSION
    commands:
      - php -v

The next syntax works but is not practical because I can't reuse PHP_VERSION:

matrix:
  PHP_VERSION:
    - deblan/php:8.1
    - deblan/php:8.2

steps:
  example:
    image: ${PHP_VERSION}
    commands:
      - php -v

Expected:

matrix:
  PHP_VERSION:
    - 8.1
    - 8.2

steps:
  foo:
    image: foo/bar:${PHP_VERSION}
  bar:
    image: foo2/bar2:${PHP_VERSION}

@zc-devs
Copy link
Contributor

zc-devs commented Oct 17, 2023

#2002

@simmstein
Copy link
Contributor Author

OK, it's now a dupplicated issue so I close it.

@qwerty287 qwerty287 removed this from the 3.x.x milestone Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing features server
Projects
None yet
Development

No branches or pull requests

5 participants