Local Builds in CircleCI 2.0

cci2-doc

#1

Documentation for this topic is now available on our documentation site: https://circleci.com/docs/2.0/local-jobs/


SSH debugging?
Managing Parallelism with the 2.0 Tests CLI
#2

Just in-case anyone is aliasing grep with colour (as I was), can you please run add –color=never to the circleci-builder-beta shell script


#3

Hello! The highlighted “sample golang project” above isn’t a link. What’s the full link please?


#4

I’m having trouble using the local build tool.

  1. Is it open source somewhere or are there more docs for it that I can peek under the hood?

  2. The exact problem I’m having is that I’m having difficulty finding my code (i.e. the code from the directory where I’m running the local build tool) inside the test container

  • I downloaded the tool locally
  • I forked/cloned the golang example (and tried this for cci-demo-react too) https://github.com/nathanleiby/cci-demo-go
  • I run circleci-builder build
    • for the Go example, I get errors that suggest it cant find my workdir: Error: path '/go/src/github.com/circleci/cci-demo-go' either does not exist or is not a directory. Did you run a checkout step or mkdir? If I remove the workdir settings from the circle.yml, the build progresses a bit further, but I’m so far unable to find my code inside the build container
    • for the react example, I get the same kind of workdir errors locally (Error: path '/home/ubuntu/demo-react-working' either does not exist or is not a directory. Did you run a checkout step or mkdir?). Removing the workdir, I start to get other errors like npm ERR! enoent ENOENT: no such file or directory, open '/package.json'

tl;dr — when you’re running a build locally, where does it mount your local code in the test container?


#5

Made a bit of progress here. Realized I need to explicitly mount my local code via

circleci-builder -v $(pwd):$WORKDIR

where WORKDIR is the value that’s set in the circle.yml.


#6

Shoot, it is a real link but we’re hosting in a private repo on GitHub right now. We’ll try to get those sample projects out in the open so you can take a look.

For now, though, I’ll remove it because wow, that is confusing.


#7

Ah, makes sense. Thanks!


#8

When I run any command after installing the CLI, it just hangs indefinitely with:

Receiving latest version of picard…


#9

Would it be possible to check permissions on the circeci-binary? I know I had to play with mine a bit to get it work properly.


#10

That did it, thanks!


#11

UPDATE: it was due to invalid yml. Error message was not so clear. Fixed it.

Don’t know exactly when it started but I think it was after a circleci-builder update. Everytime I try to build locally I get this:

====>> 0. Spin up Environment
Build-agent version 0.0.1915-bea1dcf (2016-12-26T15:42:09+0000)
Error: Error finding Picard configuration. Double check circle.yml presence.

Step failed
Task failed

#13

@travis1 Try changing /home/ubuntu/frontend to /home/circleci/frontend


#14

It looks like checkout step is skipped in local builds, so you have to mount your fs

circleci-builder build -v $(pwd):/home/ubuntu/frontend

Source: Local Builds in CircleCI 2.0


#17

sorry should be
circleci-builder build -v $(pwd):/home/ubuntu/frontend


#19

Does local-builds work with ‘executorType: machine’?


#20

No, but you’re certainly welcome to try it.


#21

@rohara Didn’t get your reply. How can someone try what isn’t working yet?


#22

You’re certainly welcome to try it to see what happens :slight_smile:


#23

I’m having some issues with local builds and networked services using pod images.

version: 2
executorType: docker
containerInfo:
  - image: opstarts/circleci
    env:
      - DISPLAY=:99
      - CHROME_BIN=/usr/bin/google-chrome
  - image: mongo:2.6.9
    cmd: ["mongod"]

Then when I try to start my application:

MongoError: failed to connect to server [127.0.0.1:27017] on first connect


#24

Do you get the same error without specifying the cmd on the mongo container?