Reputation: 8158
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:
Upvotes: 9
Views: 9237
Reputation: 8158
Instead of changing the working directory for the tasks, a workaround is to move the files into the default working directory, and a convenient way to do it is using git-sparse-checkout
like so:
git sparse-checkout set example && mv example/{*,.*} . || true
The {*,.*}
part is for also moving the dotfiles, and || true
is needed because that also tries to move .
and ..
.
Upvotes: 2
Reputation: 2132
I guess that would mess things up in relation to predefined variables in ADO which are read-only - so I don't think it's possible.
You would be probably better off by checking sources to or copying things to the default working directory right away at the start of the pipeline.
Upvotes: 2