Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable repository path #816

Closed
wants to merge 6 commits into from
Closed

Configurable repository path #816

wants to merge 6 commits into from

Conversation

stevenpall
Copy link

Having the repository being built checked out to a specific directory would be useful in various cases.

@bradrydzewski
Copy link

@stevenpall there is partial support for this feature:

git:
  path: path/to/clone

This clones the repository into /var/cache/drone/src/{ git.path }. This could be adjusted to work with absolute paths (that start with /). If is probably just a one or two line change here:
https://github.com/drone/drone/blob/0a6227930dce3e356667506bc950530a9d847c61/server/worker/docker/docker.go#L119

@bradrydzewski
Copy link

@stevenpall I think the path forward here is to alter the following configuration to respect absolute paths in the .drone.yml file:

git:
  path: path/to/clone

It could look something like this:

path := r.Repo.Host + "/" + r.Repo.Owner + "/" + r.Repo.Name
    repo := &repo.Repo{
        Name:   path,
        Path:   r.Repo.CloneURL,
        Branch: r.Commit.Branch,
        Commit: r.Commit.Sha,
        PR:     r.Commit.PullRequest,
-       Dir:    filepath.Join("/var/cache/drone/src", git.GitPath(script.Git, path)),
        Depth:  git.GitDepth(script.Git),
    }

+ if len(script.Git) != 0 && filepath.IsAbs(script.Git) {
+   repo.Dir = git.GitPath(script.Git, path)
+ } else {
+   repo.Dir = filepath.Join("/var/cache/drone/src", git.GitPath(script.Git, path))
+ }

I do agree the current default directory (/var/cache/drone) is not ideal. This is one of the reasons we'll switch to use the default WORKDIR as defined in the Dockerfile (detailed in #749). This is important for compatibility with the official Docker language stacks (see #483).

@stevenpall
Copy link
Author

@bradrydzewski That makes sense, and I like the idea of using WORKDIR to define the clone path. What do you foresee the timeline being on PR 3 of #749 getting merged in?

As an aside, I was having a pretty hard time testing the changes made in my fork since a lot of the Makefile has github.com/drone/drone hardcoded. What is the preferred method of building and running Drone from a fork like this for testing?

@stevenpall stevenpall closed this Jan 18, 2015
bot-harness pushed a commit that referenced this pull request Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants