Reputation: 792
I'm trying to setup a pipeline where the output will be written to a location based on the branch on which the pipeline was triggered.
Example: If branch was topic/124579
,
then output must be written to D:/Artifacts/topic/124579
.
But when I use this on my .gitlab-ci.yml
, the runner creates a directory with the name CI_COMMIT_BRANCH
literally: D:/Artifacts/CI_COMMIT_BRANCH
.
Here are a few things that I've tried
md D:/Artifacts/CI_COMMIT_BRANCH
results in D:/Artifacts/CI_COMMIT_BRANCH
as before
md D:/Artifacts/$CI_COMMIT_BRANCH
results in D:/Artifacts/$CI_COMMIT_BRANCH
md D:/Artifacts/"$CI_COMMIT_BRANCH"
also results in D:/Artifacts/$CI_COMMIT_BRANCH
How do I do this ?
I'm running my jobs on a self-hosted Windows runner, using cmd
as the shell.
Upvotes: 2
Views: 12312
Reputation: 1324935
Check first what kind of shell you have set in your gitlab-ci
The default one would be PowerShell Core, in which case variable substitution should use $CI_COMMIT_BRANCH
.
Try first $env:CI_COMMIT_BRANCH=$CI_COMMIT_BRANCH
But just in case you are using a deprecated CMD shell, try "%CI_COMMIT_BRANCH%"
The OP rranjik confirms in the comments:
md D:/Artifacts/"%CI_COMMIT_BRANCH%"
worked.
Upvotes: 3