Noob question: git clone into a specific directory

Ok this is a completely noob question, so apologies, our build environment has a specific requirement. The git repo needs to live in a subdirectory of $HOME called git. How do we do this? It seems as though the default is to do a git clone into $HOME. Is there a way to set this. I didn’t see this possible with a first glance at the circle.yml documentation. It says the default is to use $HOME, but doesn’t say how to change it.

Have you tried moving the repository to your desired location with cd?

Well cd doesn’t really move anything, there are a couple of tricks here:

  1. circleci automatically creates in $HOME (usually /home/ubuntu) a subdirectory named CIRCLECI_PROJECT_REPONAME (so if your repo is foo, then it puts it in /home/ubuntu/foo).
  2. our build system requires that the repo live in $HOME/git/$CIRCLE_PROJECT_REPONAME so you need to move it in the checkout: post: phase which defaults to a current working directory of $HOME/$CIRCLECI_PROJECT_REPONAME with mkdir ../git && mv ../$CIRCLE_PROJECT_REPONAME ../git && mkdir ../$CIRCLE_PROJECT_REPONAME which moves git repo somewhere else. You need the last mkdir because circleci needs that directory to exist as this is where it wants to start
  3. Now when you want to run commands, you need to make sure to set the pwd: tag properly and it should be done relative to $HOME/$CIRCLE_PROJECT_REPONAME because all those tags are relative to that spot, so it looks like pwd: ../git/$CIRCLE_PROJECT_REPONAME
  4. I’m not clear how circleci handles spaces and special characters in their shell, so I normally double quote every path name in the circle.yml file just to be safe.