woodpecker-ci / woodpecker

Woodpecker is a simple yet powerful CI/CD engine with great extensibility.
https://woodpecker-ci.org
Apache License 2.0
3.95k stars 351 forks source link

failed to parse pipeline: yaml: line 4: mapping values are not allowed in this context #2002

Closed XDream8 closed 8 months ago

XDream8 commented 1 year ago

Error: 20230715_09h12m46s_grim

WOODPECKER_VERSION = "next-b54f6eba"

Pipeline:

pipeline:
  test:
    group: test
    image: rust:${TAG}
    environment:
      - CARGO_TERM_COLOR=always
      - CARGO_BUILD_TARGET=${TARGET}
    commands:
      - rustup default stable
      - rustup target add ${TARGET}
      - rustup component add clippy
      - cargo test
      - cargo clippy

  build:
    group: build
    image: rust:${TAG}
    when:
      event: tag
    environment:
      - CARGO_TERM_COLOR=always
      - CARGO_BUILD_TARGET=${TARGET}
    commands:
      - rustup default stable
      - rustup target add ${TARGET}
      - cargo build --profile optimized
      - tar -zcvf file-rs-${TARGET}.tar.gz target/${TARGET}/optimized/file-rs

  publish:
    group: publish
    image: woodpeckerci/plugin-gitea-release
    when:
      event: tag
    settings:
      base_url: https://codeberg.org
      files:
        - "file-rs-${TARGET}.tar.gz"
      file-exists: overwrite
      api_key:
        from_secret: CODEBERG_ACCESS_TOKEN
      target: main
      title: file-rs
      skip_verify: true

matrix:
  include:
    - TARGET: x86_64-unknown-linux-musl
      TAG: alpine
    - TARGET: x86_64-unknown-linux-gnu
      TAG: latest
    - TARGET: aarch64-unknown-linux-musl
      TAG: alpine
    - TARGET: aarch64-unknown-linux-gnu
      TAG: latest
    - TARGET: x86_64-pc-windows-gnu
      TAG: latest

I followed the documentation for matrix builds but in the end this error came up.

6543 commented 1 year ago

@XDream8 what server vetsion?

XDream8 commented 1 year ago

it is codeberg ci so i suppose it is the latest version. i fixed it by using full image name image: ${IMAGE}

qwerty287 commented 11 months ago

issue on codeberg: https://codeberg.org/Codeberg/Community/issues/1152

Looks like this happens when using matrix vars in image names

qwerty287 commented 9 months ago

I tried to reproduce this, but I can't.

Using a matrix env var in images is not a problem for me, and using it with a : does work too.

xoxys commented 9 months ago

I had this issue as well. I can also try it again later.

qwerty287 commented 8 months ago

@xoxys Did you try to reproduce this?

xoxys commented 8 months ago

Thanks for the reminder. Seems to be working now https://ci.thegeeklab.de/repos/20/pipeline/119

qwerty287 commented 8 months ago

While debugging #2068, I found the reason why it's fixed in next. There was a process before that parses pipelines multiple times to check e.g. global whens and this did not respect the matrix.

Thus, the variable is substituted to an empty string, so image: rust:${TAG} becomes image: rust: and this is invalid YAML.

See https://github.com/woodpecker-ci/woodpecker/pull/2527