It's possible to set the working directory for separate scripts:
- script: foo
workingDirectory: bar
However, if all the steps are meant to run in a specific directory, it becomes repetitive to define it for each step.
Using cd
doesn't affect other steps:
- script: cd foo
- script: pwd # returns default working dir instead of foo
Two specific examples for when this issue matters are:
- when checking out multiple repos as resources, so the default working directory is one level above the checked out repos
- when running a pipeline for a project that's located in a subdirectory (like in a monorepo)