Drone: builds failing and clone related issue

Hey Guys,

New to using drone CI, running into some basic problems which I am sure someone can help (maybe I have been staring the problem for too long :slight_smile: )

I have been trying to test custom logic using this link: Custom logic link. Just removed the step git checkout $DRONE_COMMIT. Here is the output:

+ git clone https://github.com/octocat/hello-world.git .
Cloning into '.'...
+ go build
can't load package: package .: no Go files in /drone/src

This fails in the build step. I tried looking for the path /drone/src but couldnt find this path anywhere

I did read the documents on how drone clones repository from the links this and this. Some of my questions are:

  • Is the git clone temporary? As I did try to find the cloned repos, and I couldn’t (both inside the agent and servers containers) or in shared docker volume.

More information, here is my docker-compose configuration:

version: '3.7'

    container_name: drone_server
    image: drone/drone:latest
      - xxxx:xxxx
      - /var/lib/drone:/data
      - ./drone-server.env
    restart: always
      - DRONE_GITHUB_SERVER=https://github.com
      - DRONE_TLS_AUTOCERT=false
      - DRONE_LOGS_TRACE=true
      - DRONE_LOGS_PRETTY=true
      - DRONE_LOGS_COLOR=true

    container_name: drone_agent
    image: drone/agent:latest
      - xxxx:xxxx
      - /var/run/docker.sock:/var/run/docker.sock
      - drone-server
    restart: always
      - ./drone-agent.env
      - DRONE_RUNNER_NAME=mazdoor
      - DRONE_LOGS_TRACE=true
      - DRONE_LOGS_PRETTY=true
      - DRONE_LOGS_COLOR=true

Passing the env vars in two files drone-agent.env and drone-server.env.

Can someone assist in this. I know this community to be highly engaging and helpful, hoping someone to point out issues in either the docker config or the actual drone yaml file.


+ git clone https://github.com/octocat/hello-world.git .
Cloning into '.'... + go build can't
load package: package .: no Go files in /drone/src

:wave: hey there, based on the output you posted it would appear you copy / pasted the example from the documentation and you are using the configuration as-is.

Please note that this example in the documentation is more like pseudo code and is not meant to be a working example. You should replace the repository url and the build step with configuration parameters that are specific to your project.

kind: pipeline
type: docker
name: default

  disable: true

  - name: clone
    image: alpine/git
-   - git clone https://github.com/octocat/hello-world.git .
+   - git clone <insert your repository address here> .
    - git checkout $DRONE_COMMIT

  - name: build
-   image: golang
+   image: <insert your docker image here>
-   - go build
-   - go test
+   - <insert your commands here>

the workspace directory (read more here), in which you are cloning your code, is a temporary docker volume that is destroyed when the pipeline is complete. Drone does not clone any code inside the agent or server container.

This was somewhat answered above, but for completeness, the /drone/src directory is the workspace directory. It is the temporary volume mounted inside your pipeline containers. It is the working directory of all pipeline steps.

1 Like

Hi Brad,

Thank you for the detailed explanation. It makes a lot of sense now.

On the GitHub repo, apologies for that, for some reason I was expecting some golang files to be there (which weren’t present my mistake, and it’s obvious go build step will fail ).

I am testing pipelines now, will let you know how it goes (hopefully they will work, i know there is a potential problem for SSH github-clone that i have to solve). Thank you for taking the time to give detailed explanation.