Running Checkout on Local Build


#1

I’d like to run the checkout step in a local build. My local checkout includes test environment parameters that are specific to my local environment which override the global parameters that are based on environment variables. This causes the tests to fail because, for example, my local database user and database name are different then the ones set up for CI. I’ve tried running

circleci-builder build --skip-checkout false

but to no avail.


#2

Hi David,

I don’t quite understand what you mean by a local checkout. My understanding of the tool is that you run it in the repo you want to build and it mounts that folder into Docker. Could you provide an example?


#3

Hey Eric!

So let me try to detail the problem a little bit more. I have a source code repository locally with the appropriate CircleCI 2.0 YAML file in the repository. The way I’m running the local build with CircleCI currently is:

circleci-builder build -v $(pwd):/opt/app

This mounts the local directory to /opt/app which is also the working directory declared by the circle.yaml file.

The problem is that my local source code repository is set up for local testing against my computer. For example, the default configuration files utilize environment variables. Locally, I have configuration files (that are excluded from git) that overrides the default configuration; for example, I have one that specifies the test database as postgres://localhost/app_test. But the CircleCI build has a different PostgreSQL database setup, and it expects to pass it via environment variable. But that environment variable is being shadowed by my local configuration file that isn’t expected to be present during Circle runs.

Configuration I can solve in less than elegant ways, but then I also have build artifacts that don’t work because of operating system differences. My local artifacts are compiled for darwin (macOS), but the CircleCI build will expect linux (Ubuntu), and the compile system spends some time trying to load files it thinks are already compiled, only to throw them out when it realizes they aren’t compatible.

So in essence, in my mind, it is easier to solve this problem by having the local build clone the repository on the current branch (and thereby excluding all the files in .gitignore). I’m not sure this is the best way to solve it, but it did throw me for a loop last week while setting up a build. And it makes it difficult for us to allow for both actual local testing and local CircleCI testing.


#4

Okay, I think I get your issue. However, I also circled back around to your first post. I tried running

circleci-builder build --skip-checkout false

As you did and saw the same “skipping this step” under checkout code. I also tried:

circleci-builder build --skip-checkout=false

And this attempted to get my ssh key credential. I think you were bit by invalid syntax? I’ll pass on a note to update the help doc.

Can you let me know if this solves all your issues? It sounds like you were building the artifacts outside of docker (circleci-builder) and then trying to use them in circleci-builder, yes?


#5

Gah! That’s it! Two notes based on that:

  • It would help if the documentation included the expected format of non-default values
  • The system now asks me for my SSH key passphrase but it seems like stdin isn’t being redirected properly since the input I give goes directly to my terminal rather than to the running docker container.

#6

Yep, I totally agree with you about the documentation!

As for the password: I ran into the same issue that you did. I’m asking around to see if there’s a way around this, otherwise this is a bug.

As a hack workaround, you can mount your project folder into the container, then checkout from that folder. As an example:

circleci-builder build --skip-checkout=false --repo-url="/fake-remote" --volume="/projects/test":"/fake-remote"

#7

Just following up–I’ve filed this as a bug.


#8

Thanks Eric!


#9