Skip to content

fix: prevent .setup_job_path from exiting early when no path is set

Summary

When the .setup_job_path logic is used, the job exits prematurely (exit 0) whenever PRIVATE_JOB_PATH is not set or is ".".
This causes all subsequent scripts in the job to be skipped, even though no directory change is required.

Related

  • Relates to: improvement of job templates using PRIVATE_JOB_PATH.

Context / Problem Statement

Currently, when including the component in GitLab CI, if no cd is needed, the function uses exit 0.
This results in jobs that succeed but effectively execute nothing beyond the path handling step, as shown below:

stages:
  - lint
  - test
  - build
  - audit
  - outdated

variables:
  BUN_VERSION: "1.2"

include:
  - component: $CI_SERVER_FQDN/orbyon/components/bun/lint@1
    inputs:
      job_name: "lint_code"
      job_stage: "lint"
      job_cache:
        - key: ${CI_COMMIT_REF_SLUG}-bun-deps
          policy: pull
          paths:
            - node_modules/
      bun_run_install: true
      bun_version: $BUN_VERSION

Example execution log:

$ path="${PRIVATE_JOB_PATH:-}"
No job_path set (or '.'), staying in: /builds/orbyon/website
Job succeeded

The problem is that the rest of the script: section never runs, breaking the expected flow. The correct behavior should be to skip the cd only while still executing the subsequent steps of the job.