Make sure each script: starts in the intended directory

Created on 3 February 2025, 2 months ago

Problem/Motivation

When working on 📌 Add custom variables to set before_script commands in upstream project Active to test Add basepath parameter to PHP Code Sniffer Active I realised that many of the script: sections in the template rely/expect/assume the working directory is the default from when the job started. But any custom before_script: could have changed the working directory, which would caase failure in the script:

Proposed resolution

At the start of every script: execute the require cd $CI_PROJECT_DIR/path/we/need && pwd to fix and confirm the working directory.

This has several benefits

  • It will save developer time working out why the job fails
  • It will reduce support hours
  • It documents very clearly in code and log where the job script is being run.
📌 Task
Status

Active

Component

gitlab-ci

Created by

🇬🇧United Kingdom jonathan1055

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024