How to trigger build when running Drone locally?

Hello,

Thanks for the next response.

My docker-compose.yml from doc is:

services:
  drone-server:
    image: drone/drone:0.5
    ports:
      - 80:8000
    volumes:
      - ./drone:/var/lib/drone/
    restart: always
    environment:
      - DRONE_OPEN=true
      - DRONE_GITHUB=true
      - DRONE_GITHUB_CLIENT=${DRONE_GITHUB_CLIENT}
      - DRONE_GITHUB_SECRET=${DRONE_GITHUB_SECRET}
      - DRONE_SECRET=${DRONE_SECRET}

  drone-agent:
    image: drone/drone:0.5
    command: agent
    restart: always
    depends_on: [ drone-server ]
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      - DRONE_SERVER=ws://drone-server:8000/ws/broker
      - DRONE_SECRET=${DRONE_SECRET}

My docker ps is:

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
xxxxxxxxxxxx        drone/drone:0.5     "/drone agent"      .... ago         Up ...          8000/tcp               drone_drone-agent_1
yyyyyyyyyyyy        drone/drone:0.5     "/drone server"     ... ago         Up ...          0.0.0.0:80->8000/tcp   drone_drone-server_1

My question is : How to trigger a build for the repo xxxx/yyyy?

I try docker exec -it yyy /drone, I show the help, but impossible to trigger :confused:

How to trigger a build for the repo xxxx/yyyy?

When you activate a repository in the drone user interface, drone adds post-commit hooks to your repository in GitHub (or Bitbucket, etc). When you push to your repository, GitHub uses the webhook to trigger a build in Drone.

So one triggers a Drone build by pushing code to the repository.

Thanks for your answer.

But actually, I just test drone on my computer (the address is 0.0.0.0).

But I want to force build with a command because the hooks doesn’t work.

(eg: old drone start xxx/yyy)

This is a fake project^^

Please note there is no way to trigger a new build outside of webhooks. Drone is built and optimized to work with webhooks.

You can use a service like ngrok to expose your local drone instance to github. Ngrok will tunnel traffic from its servers to your laptop. See https://ngrok.com/

You can also attempt to manually curl the drone server and send the GitHub payload. You will need to accurately re-construct the GitHub message, including headers and payload, and webhook url with token, which you can find in the GitHub user interface.

curl -X POST --data @payload.json \
	-H "Content-Type: application/json" \
	-H "X-GitHub-Delivery: 55c50d00-c223-11e6-934e-724510b231d7" \
	-H "X-GitHub-Event: push" \
	http://localhost:8080/hook?access_token=eyJhbGciOiJI.........

The above command is what I use locally when testing.

Alternatively if you do not need the drone user interface, you can run builds directly from the command line without a drone server, using the drone exec command. See drone exec | Drone

1 Like

Big thanks, I’ve just used ngork now.

BUT… are-you shure that there’s no commad-line :frowning:

Yes, I am sure. There is no command to launch a new build like this (ie fetch HEAD from GitHub). There are commands to launch new builds for commits that already exist in the Drone database. I do not believe, however, this is going to solve your issue.

There is a command to re-start an existing build:

drone build start foo/bar 1

There is a command to re-start an existing build with a new build number (good for nighty jobs):

drone build start --fork foo/bar 1

There is a command to run a build locally from the command line and write the results to your console. This is intended for locally testing your yaml configuration, and does not contact the drone server

drone exec
1 Like

Thanks for all!

Sorry for my english syntaxe. :wink: