dependabot-script icon indicating copy to clipboard operation
dependabot-script copied to clipboard

How to set DIRECTORY_PATH

Open vv12131415 opened this issue 4 years ago • 2 comments

Hi! I can't set DIRECTORY_PATH correctly.

Currently my .gitlab-ci.yml looks like this


.dependabot:
  image: dependabot/dependabot-core
  variables:
    PACKAGE_MANAGER: $CI_JOB_NAME
  before_script:
    - bundle install -j $(nproc) --path vendor
  script: bundle exec ruby ./generic-update-script.rb
  cache:
    paths:
      - vendor/
  only:
    - schedules

npm_and_yarn:
  extends: .dependabot
  only:
    variables:
      - $PACKAGE_MANAGER_SET =~ /(\bnpm|yarn\b)/
      - $DIRECTORY_PATH =~ /Frontend/

The error is that it still tries to get files from the root of the repo that I'm trying to update dependencies. So no variable cant is not applied here.

Why I did $DIRECTORY_PATH =~ /Frontend/? Because if I do

  • - DIRECTORY_PATH =~ /Frontend/ - jobs:npm_and_yarn:only variables invalid expression syntax
  • - $DIRECTORY_PATH = /Frontend/ - jobs:npm_and_yarn:only variables invalid expression syntax
  • - $DIRECTORY_PATH = Frontend - jobs:npm_and_yarn:only variables invalid expression syntax
  • - $DIRECTORY_PATH = "Frontend" - jobs:npm_and_yarn:only variables invalid expression syntax
  • - $DIRECTORY_PATH: "Frontend" - gitlab just gives 500 error
  • - DIRECTORY_PATH: "Frontend" - gitlab just gives 500 error

I've tried a lot of things, none worked. What is the correct way of setting DIRECTORY_PATH variable?

vv12131415 avatar Apr 09 '20 21:04 vv12131415

@vladyslavstartsev You have all the documentation online: https://docs.gitlab.com/ee/ci/yaml/README.html#variables

only: variables: object is for restricting related jobs to when variables are set to the specified values. variables: is for defining variables.

LeoColomb avatar Apr 10 '20 10:04 LeoColomb

npm_and_yarn:
  extends: .dependabot
  variables:
    DIRECTORY_PATH: Frontend
  only:
    variables:
      - $PACKAGE_MANAGER_SET =~ /(\bnpm|yarn\b)/

okay, this one works

vv12131415 avatar Apr 13 '20 12:04 vv12131415