WIP: Added custom per-job BuildsDir
What does this MR do?
Adds the ability to add a "builddir" option per-job within your .gitlab-ci.yml file
Why was this MR needed?
There are a few use cases for this. My particular issue was that I wanted to use a Docker
executor with a custom per-job image that required my code and artifacts to be in different directories at each stage or job. For example, the golang:1.7.1
image sets the $GOPATH to /go/
. By default, my code would be checked out in /build/
or the value that is set for builds_dir
in the runner configuration. I didn't want to reconfigure my runner to use /go
as the builds_dir
because I intend on using the same runner for multiple jobs through the pipeline that use different images.
Are there points in the code the reviewer needs to double check?
Keep in mind that this currently affects all executors and shells, from what I understand. This may not be the best approach since there are no checks or options to push the custom build directories down the stack. It might be nice to add an option for SSH / SHELL executors to have a prepended parent directory defined in the runner configuration.
Does this MR meet the acceptance criteria?
-
Documentation created/updated - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Branch has no merge conflicts with master
(if you do - rebase it please)
What are the relevant issue numbers?
Merge request reports
Activity
I have two possible solutions for the potential concern for abuse on this option:
-
We can have a boolean value (0/off by default) in the runner configuration that would allow for overriding of the build directory.
allow_custom_build_dir
-
We can have a string value (blank by default) in the runner configuration that will be prepended to all custom build directories.
custom_build_dir_base
Obviously we could implement a hybrid of the two, which seems feasible. What this could allow, though, is for the option to set the custom build dirs per runner. We can also allow for custom base directories where the custom build directories are allowed, enabling people to still clone their projects in custom places. In my example from the MR description, I would simply have to change my
$GOPATH
to "/build/base/go/" and mybuilddir
within the.gitlab-ci.yml
file to "/build/base/go/src"-
mentioned in issue #1918