jcrizk
jcrizk

Reputation: 615

Gitlab regex not working in needs keyword

I'm not sure if I'm the problem or if needs:ref is the issue.

I have a job that should download artifacts from another job in a different repo. The ref I'm trying to match on is a tag named "v0.1.1-dev.3".

my-job:
  stage: build
  script:
  # does stuff
  needs:
    - project: my-group/my-project
      job: my-other-job-in-another-repo
      ref: /^v[0-9]+\.[0-9]+\.[0-9]+-dev\.[0-9]+$/
      artifacts: true

The main problem is that the regex refuses to match in needs:ref, but it's the exact same regex that I use in my-other-job-in-another-repo in the only keyword.

my-other-job-in-another-repo:
  stage: build
  script:
  # does stuff
  only:
    - /^v[0-9]+\.[0-9]+\.[0-9]+-dev\.[0-9]+$/

However, this does work for whatever reason.

my-job:
  stage: build
  script:
  # does stuff
  needs:
    - project: my-group/my-project
      job: my-other-job-in-another-repo
      ref: v0.1.1-dev.3
      artifacts: true

Does anyone know why the regex doesn't work in needs:ref, but it works fine with the literal string?

Upvotes: 0

Views: 836

Answers (1)

knittl
knittl

Reputation: 265231

According to the GitLab 14.0 docs, cross-project artifact download with the needs: keyword is only supported in GitLab Premium or higher tiers.

The documentation doesn't mention needs:ref: supporting globs or wildcards. I can't say for sure, but I assume only a single ref is supported, otherwise GitLab would be unable to pick the "right" artifact to download (latest job of all matching ref? latest job of the first matching ref? latest job of the matching ref with the newest commit?)

Upvotes: 1

Related Questions