### Drone Pipeline Execution Log Example Source: https://docs.drone.io/quickstart/cli Example output from `drone exec`, showing the streamed logs from the pipeline steps. ```bash $ drone exec [test:1] + echo hello [test:2] hello [test:3] + echo world [test:4] world ``` -------------------------------- ### Install Drone CLI on Windows Source: https://docs.drone.io/quickstart/cli Installs the Drone command line interface on Windows using Scoop. ```bash scoop install drone ``` -------------------------------- ### Install Drone CLI on macOS Source: https://docs.drone.io/quickstart/cli Installs the Drone command line interface on macOS using Homebrew. ```bash brew install drone-cli ``` -------------------------------- ### Drone CI: Multiple Pipelines Source: https://docs.drone.io/quickstart/docker This example illustrates how to define multiple independent pipelines within the same configuration file. Each pipeline has its own name and steps. ```yaml kind: pipeline type: docker name: en steps: - name: greeting image: alpine commands: - echo hello world --- kind: pipeline type: docker name: fr steps: - name: greeting image: alpine commands: - echo bonjour monde ``` -------------------------------- ### Drone CI: Multiple Pipeline Steps Source: https://docs.drone.io/quickstart/docker This example shows how to define multiple steps within a single Drone CI pipeline. Each step is executed sequentially. ```yaml kind: pipeline type: docker name: greeting steps: - name: en image: alpine commands: - echo hello world - name: fr image: alpine commands: - echo bonjour monde ``` -------------------------------- ### Drone CI: Using Plugins for Third-Party Integration Source: https://docs.drone.io/quickstart/docker This example shows how to use a Drone plugin (Slack) to integrate with third-party systems, such as sending notifications. It includes settings for the plugin. ```yaml kind: pipeline type: docker name: default steps: - name: test image: golang:1.13 commands: - go build - go test -v - name: notify image: plugins/slack settings: channel: dev webhook: https://hooks.slack.com/services/... ``` -------------------------------- ### Drone CI: Using Docker Images from Registries Source: https://docs.drone.io/quickstart/docker This example demonstrates using a Docker image from a specific registry (Google Container Registry) for pipeline steps. It includes build and test commands. ```yaml kind: pipeline type: docker name: default steps: - name: test image: gcr.io/library/golang commands: - go build - go test -v ``` -------------------------------- ### Dockerfile for Drone CI Plugin Source: https://docs.drone.io/plugins/tutorials/golang This Dockerfile creates a minimal image for the webhook plugin. It starts from a lightweight Alpine base image, adds the compiled Go binary, installs certificates, and sets the binary as the container's entrypoint. ```dockerfile FROM alpine ADD webhook /bin/ RUN apk -Uuv add ca-certificates ENTRYPOINT /bin/webhook ``` -------------------------------- ### Drone Pipeline Configuration with Named Pipeline Source: https://docs.drone.io/quickstart/cli An example Drone pipeline configuration with a pipeline named 'test'. This is used when you have multiple pipelines or want to specify a non-default pipeline name. ```yaml kind: pipeline type: docker name: test steps: - name: dist image: node commands: - npm install - npm run dist ``` -------------------------------- ### Download and Install Anka Source: https://docs.drone.io/runner/vm/drivers/anka Downloads the latest Anka virtualization package from veertu.com and installs it on the system. It first determines the latest version's filename and then proceeds with the download and installation. ```bash FULL_FILE_NAME="$(curl -Ls -r 0-1 -o /dev/null -w %{url_effective} https://veertu.com/downloads/anka-virtualization-latest | cut -d/ -f5)" curl -S -L -o ./$FULL_FILE_NAME https://veertu.com/downloads/anka-virtualization-latest sudo installer -pkg $FULL_FILE_NAME -tgt / ``` -------------------------------- ### Execute Specific Drone Pipeline Steps Source: https://docs.drone.io/quickstart/cli Executes only the 'build' and 'test' steps of a Drone pipeline using the `--include` flag. ```bash drone exec --include=build --include=test ``` -------------------------------- ### Drone Pipeline Emulating Secrets Source: https://docs.drone.io/quickstart/cli An example Drone pipeline that uses secrets for environment variables. Secrets are sourced from a file specified with `--secret-file`. ```yaml kind: pipeline type: docker name: default steps: - name: test environment: USERNAME: from_secret: USERNAME PASSWORD: from_secret: PASSWORD ``` -------------------------------- ### Install Drone CLI on Linux Source: https://docs.drone.io/cli/install Installs the Drone CLI on Linux by downloading the latest amd64 binary, extracting it, and placing it in the system's PATH. This method is suitable for systems where direct binary installation is preferred. ```bash curl -L https://github.com/harness/drone-cli/releases/latest/download/drone_linux_amd64.tar.gz | tar zx sudo install -t /usr/local/bin drone ``` -------------------------------- ### Example Digital Ocean Pool Setup Source: https://docs.drone.io/runner/vm/drivers/digitalocean An example YAML configuration file for setting up Digital Ocean runner pools. It demonstrates how to define multiple pools with specific instance configurations, including name, type, pool size, and resource limits. ```YAML version: "1" instances: - name: ubuntu default: true type: digitalocean pool: 1 # total number of warm instances in the pool at all times limit: 4 # limit the total number of running servers. If exceeded block or error. platform: os: linux arch: amd64 spec: account: region: nyc2 image: docker-18-04 size: s-2vcpu-8gb ``` -------------------------------- ### Start Drone Server Docker Container Source: https://docs.drone.io/server/provider/github Starts the Drone server Docker container with essential configurations. It maps volumes for data persistence, sets environment variables for GitHub integration and RPC secrets, exposes ports, and configures restart policies. ```Bash docker run \ --volume=/var/lib/drone:/data \ --env=DRONE_GITHUB_CLIENT_ID=your-id \ --env=DRONE_GITHUB_CLIENT_SECRET=super-duper-secret \ --env=DRONE_RPC_SECRET=super-duper-secret \ --env=DRONE_SERVER_HOST=drone.company.com \ --env=DRONE_SERVER_PROTO=https \ --publish=80:80 \ --publish=443:443 \ --restart=always \ --detach=true \ --name=drone \ drone/drone:2 ``` -------------------------------- ### List Available macOS Installers Source: https://docs.drone.io/runner/vm/drivers/anka Lists the available full installer versions for macOS that can be downloaded using the softwareupdate command. ```shell softwareupdate --list-full-installers ``` -------------------------------- ### Basic Drone Pipeline Configuration Source: https://docs.drone.io/quickstart/cli A basic Docker pipeline configuration for local testing. It defines a pipeline named 'default' with a single step that echoes 'hello' and 'world'. ```yaml kind: pipeline type: docker name: default steps: - name: test image: alpine commands: - echo hello - echo world ``` -------------------------------- ### Install Homebrew and Docker Source: https://docs.drone.io/runner/vm/drivers/anka Installs Homebrew package manager and then uses it to install Docker Desktop. Note: Docker is not supported on M1 Architectures. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install wget brew install docker --cask ``` -------------------------------- ### Install Drone CLI on macOS (Binary) Source: https://docs.drone.io/cli/install Installs the Drone CLI on macOS by downloading the latest amd64 binary, extracting it, and copying it to the system's binary directory. This is a direct installation method for macOS users. ```bash curl -L https://github.com/harness/drone-cli/releases/latest/download/drone_darwin_amd64.tar.gz | tar zx sudo cp drone /usr/local/bin ``` -------------------------------- ### Setup Digital Ocean Instance with Drone Runner AWS Source: https://docs.drone.io/runner/vm/configuration/setup This example shows how to use the './drone-runner-aws setup' command for Digital Ocean integration. It requires the '--digital-ocean-pat' flag with a Personal Access Token. The output includes instance creation, firewall configuration, and health check status. ```bash ./drone-runner-aws setup --digital-ocean-pat XXXXXXXXX INFO[0000] setup: using digital ocean INFO[0000] no pool file provided INFO[0000] in memory pool is using digitalocean INFO[0000] digitalocean: creating instance setup-testpool-1655379844 driver=digitalocean hibernate=false image=docker-18-04 pool=testpool INFO[0001] digitalocean: instance created setup-testpool-1655379844 driver=digitalocean hibernate=false image=docker-18-04 pool=testpool INFO[0003] digitalocean: firewall configured setup-testpool-1655379844 driver=digitalocean hibernate=false image=docker-18-04 pool=testpool DEBU[0003] find instance network driver=digitalocean hibernate=false image=docker-18-04 name=setup-testpool-1655379844 pool=testpool DEBU[0063] find instance network driver=digitalocean hibernate=false image=docker-18-04 name=setup-testpool-1655379844 pool=testpool INFO[0064] setup: instance logs for 304473745: no logs here TRAC[0064] setup: running healthcheck and waiting for an ok response TRAC[0129] RetryHealth: health check completed duration=1m5.3480743s TRAC[0129] LE.RetryHealth check complete response="&{Version:0.1.0 DockerInstalled:true GitInstalled:true LiteEngineLog:time=\"2022-06-16T11:45:44Z\" level=info msg=\"server listening at port :9079\" time=\"2022-06-16T11:45:44Z\" level=info msg=\"checking git is installed\" time=\"2022-06-16T11:45:44Z\" level=info msg=\"git is installed\" time=\"2022-06-16T11:45:44Z\" level=info msg=\"checking docker is installed\" CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES time=\"2022-06-16T11:45:44Z\" level=info msg=\"docker is installed\" time=\"2022-06-16T11:46:13Z\" level=info msg=\"handler: HandleHealth()\" time=\"2022-06-16T11:46:13Z\" level=info msg=\"checking docker is installed\" CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES time=\"2022-06-16T11:46:13Z\" level=info msg=\"docker is installed\" time=\"2022-06-16T11:46:13Z\" level=info msg=\"checking git is installed\" time=\"2022-06-16T11:46:13Z\" level=info msg=\"git is installed\" OK:true}" Pool file: version: "1" instances: - name: testpool default: true type: digitalocean pool: 1 limit: 2 platform: os: linux arch: amd64 spec: account: pat: XXXXXXXXX DEBU[0130] deleting droplet driver=amazon id="[304473745]" DEBU[0130] droplet deleted driver=amazon id="[304473745]" TRAC[0130] digitalocean: VM terminated driver=amazon id="[304473745]" ``` -------------------------------- ### Install Drone CLI on Windows (Scoop) Source: https://docs.drone.io/cli/install Installs the Drone CLI on Windows using the Scoop package manager. This command adds the Drone CLI to your system, making it accessible from the command line. ```shell scoop install drone ``` -------------------------------- ### Drone Runner Exec Configuration Example Source: https://docs.drone.io/runner/exec/installation/linux Example of an environment variable file for configuring the Drone Runner Exec, specifying connection details to the Drone server. ```env DRONE_RPC_PROTO=https DRONE_RPC_HOST=drone.company.com DRONE_RPC_SECRET=super-duper-secret ``` -------------------------------- ### Emulate Metadata using Environment Variables Source: https://docs.drone.io/quickstart/cli Sets the Drone system host metadata using an environment variable before executing the pipeline. ```bash DRONE_SYSTEM_HOST=drone.company.com drone exec ``` -------------------------------- ### Go Pipeline: Build and Test Source: https://docs.drone.io/pipeline/docker/examples/languages/golang_gopath A basic Drone pipeline configuration for a Go project that executes 'go get' and 'go test' commands within a golang Docker container. ```yaml kind: pipeline name: default workspace: base: /go path: src/github.com/octocat/hello-world steps: - name: test image: golang commands: - go get - go test ``` -------------------------------- ### Maven CI Pipeline Example Source: https://docs.drone.io/pipeline/docker/examples/languages/maven A Drone CI pipeline configuration for a Maven project. It defines a single step that runs Maven install and test commands within a specified Docker image. ```yaml kind: pipeline name: default steps: - name: test image: maven:3-jdk-10 commands: - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - mvn test -B ``` -------------------------------- ### Start Drone Server Docker Container Source: https://docs.drone.io/server/provider/gitea Starts the Drone server as a Docker container, configuring it with environment variables for Gitea integration, RPC secret, server host, and protocol. It maps ports and sets the container to restart automatically. ```Bash docker run \ --volume=/var/lib/drone:/data \ --env=DRONE_GITEA_SERVER=https://try.gitea.io \ --env=DRONE_GITEA_CLIENT_ID=05136e57d80189bef462 \ --env=DRONE_GITEA_CLIENT_SECRET=7c229228a77d2cbddaa61ddc78d45e \ --env=DRONE_RPC_SECRET=super-duper-secret \ --env=DRONE_SERVER_HOST=drone.company.com \ --env=DRONE_SERVER_PROTO=https \ --publish=80:80 \ --publish=443:443 \ --restart=always \ --detach=true \ --name=drone \ drone/drone:2 ``` -------------------------------- ### Execute Drone Pipeline with Secret File Source: https://docs.drone.io/quickstart/cli Executes a Drone pipeline, providing secrets from a file named 'secrets.txt' using the `--secret-file` flag. ```bash drone exec --secret-file=secrets.txt ``` -------------------------------- ### Execute Specific Named Drone Pipeline Source: https://docs.drone.io/quickstart/cli Executes a specific Drone pipeline named 'test' using the `--pipeline` flag. ```bash drone exec --pipeline=test ``` -------------------------------- ### Emulate Repository Branch Metadata Source: https://docs.drone.io/quickstart/cli Sets the repository branch to 'master' when executing a Drone pipeline locally using the `--branch` flag. ```bash drone exec --branch=master ``` -------------------------------- ### Drone CI: Service Containers for Integration Tests Source: https://docs.drone.io/quickstart/docker This configuration defines a service container (Redis) that runs alongside the main pipeline steps. This is useful for integration testing. ```yaml kind: pipeline type: docker name: default steps: - name: test image: golang:1.13 commands: - go build - go test -v services: - name: redis image: redis ``` -------------------------------- ### Start Drone Server with Docker Source: https://docs.drone.io/server/provider/bitbucket-server This command starts the Drone server container using Docker. It mounts necessary volumes for data and private keys, sets various environment variables for configuration (Git credentials, Bitbucket details, server host/protocol, RPC secret), maps ports, and configures restart policies and container naming. The image used is 'drone/drone:2'. ```bash docker run \ --volume=/var/lib/drone:/data \ --volume=/etc/bitbucket/key.pem:/etc/bitbucket/key.pem \ --env=DRONE_GIT_PASSWORD=7c229228a77d2cbddaa61ddc78d45e \ --env=DRONE_GIT_USERNAME=x-oauth-token \ --env=DRONE_GIT_ALWAYS_AUTH=false \ --env=DRONE_STASH_SERVER=https://bitbucket.company.com \ --env=DRONE_STASH_CONSUMER_KEY=OauthKey \ --env=DRONE_STASH_PRIVATE_KEY=/etc/bitbucket/key.pem \ --env=DRONE_SERVER_HOST=drone.company.com \ --env=DRONE_SERVER_PROTO=https \ --env=DRONE_RPC_SECRET=super-duper-secret \ --publish=80:80 \ --publish=443:443 \ --restart=always \ --detach=true \ --name=drone \ drone/drone:2 ``` -------------------------------- ### Drone CI Pipeline Configuration Example Source: https://docs.drone.io/pipeline/macstadium/syntax/steps An example of a basic Drone CI pipeline configuration for a DigitalOcean runner, defining backend and frontend steps with their respective commands. ```yaml kind: pipeline type: digitalocean name: default steps: - name: backend commands: - go build - go test - name: frontend commands: - npm install - npm test ``` -------------------------------- ### Drone Pipeline Configuration Example Source: https://docs.drone.io/pipeline/digitalocean/syntax/steps A basic Drone CI pipeline configuration for a DigitalOcean runner, demonstrating a multi-step process with separate commands for backend and frontend builds. ```yaml kind: pipeline type: digitalocean name: default token: from_secret: token steps: - name: backend commands: - go build - go test - name: frontend commands: - npm install - npm test ``` -------------------------------- ### Install and Start Drone Runner Service Source: https://docs.drone.io/runner/exec/installation/macos Installs and starts the Drone exec runner as a service. Includes options for running as a specific user. ```bash drone-runner-exec service install drone-runner-exec service start ``` ```bash sudo drone-runner-exec service install --config=/Users//.drone-runner-exec/config sudo defaults write /Library/LaunchDaemons/drone-runner-exec UserName sudo drone-runner-exec service start ``` -------------------------------- ### Install and Start Drone Runner Exec Service Source: https://docs.drone.io/runner/exec/installation/linux Installs the Drone Runner Exec as a system service and then starts the service. This may require superuser privileges. ```Bash drone-runner-exec service install drone-runner-exec service start ``` -------------------------------- ### Install and Start Drone Runner Exec Service Source: https://docs.drone.io/runner/exec/installation/windows Installs the Drone Runner Exec as a Windows service and then starts the service. This allows the runner to operate in the background. ```powershell $drone-runner-exec.exe service install $drone-runner-exec.exe service start ``` -------------------------------- ### Drone CI Pipeline Initialization Example Source: https://docs.drone.io/pipeline/docker/examples/services/couchdb This snippet illustrates a Drone CI pipeline configuration, similar to the basic example, focusing on ensuring adequate initialization time for the CouchDB service. It includes a 'sleep 15' command in the test step to allow the database instance to start properly before attempting to connect. ```yaml kind: pipeline name: default steps: - name: test image: coucdb:2.2 commands: - sleep 15 - curl http://database:5984 ... ``` -------------------------------- ### Drone Pipeline Configuration Example Source: https://docs.drone.io/pipeline/aws/syntax/steps A basic Drone CI pipeline configuration defining a virtual machine pipeline named 'default' using an Ubuntu runner. It includes two steps: 'backend' using a Go image and 'frontend' using a Node image, each with specific build commands. ```yaml kind: pipeline type: vm name: default pool: use: ubuntu steps: - name: backend image: golang commands: - go build - go test - name: frontend image: node commands: - npm install - npm test ``` -------------------------------- ### Drone CI: Sourcing Secrets for Sensitive Parameters Source: https://docs.drone.io/quickstart/docker This example demonstrates how to securely source sensitive parameters, like webhook endpoints, from Drone secrets. The 'webhook' setting is configured to use a secret named 'endpoint'. ```yaml kind: pipeline type: docker name: default steps: - name: test image: golang:1.13 commands: - go build - go test -v - name: notify image: plugins/slack settings: channel: dev webhook: from_secret: endpoint ``` -------------------------------- ### Drone Pipeline Configuration Example Source: https://docs.drone.io/pipeline/aws/syntax/trigger A basic Drone CI pipeline configuration for a virtual machine environment using Ubuntu. It defines a build step with Go commands for building and testing. ```yaml kind: pipeline type: vm name: default pool: use: ubuntu steps: - name: build image: golang commands: - go build - go test trigger: branch: - master ``` -------------------------------- ### Initialize MySQL Container and Connect Source: https://docs.drone.io/pipeline/docker/examples/services/mysql This example addresses potential initialization issues when connecting to a MySQL container. It includes a 'sleep 15' command in the steps to ensure the database has sufficient time to start before attempting a connection. ```yaml kind: pipeline name: default steps: - name: test image: mysql commands: - sleep 15 - mysql -u root -h database ``` -------------------------------- ### Example Go Plugin Usage Source: https://docs.drone.io/plugins/support This snippet demonstrates how to configure a pipeline to use a Go-based plugin. It shows the basic structure of a Drone pipeline and how to specify the plugin image and settings. ```yaml kind: pipeline type: docker name: default steps: - name: example-go-plugin image: plugins/example-go settings: # Plugin specific settings here ``` -------------------------------- ### Example Drone CI Pipeline Configuration Source: https://docs.drone.io/plugins/overview This snippet shows a complete Drone CI pipeline configuration using Docker and Slack plugins. It defines build, publish, and notify steps, demonstrating how to specify images and settings for each step. ```yaml kind: pipeline type: docker name: default steps: - name: build image: golang commands: - go get - go test - go build - name: publish image: plugins/docker settings: username: kevinbacon password: pa55word repo: foo/bar tags: - 1.0.0 - 1.0 - name: notify image: plugins/slack settings: channel: developers username: drone ``` -------------------------------- ### Install Drone CLI on macOS (Homebrew) Source: https://docs.drone.io/cli/install Installs the Drone CLI on macOS using the Homebrew package manager. This command adds the Drone tap and then installs the drone package, simplifying the installation and update process. ```shell brew tap drone/drone brew install drone ``` -------------------------------- ### Initialize MariaDB and Connect Source: https://docs.drone.io/pipeline/docker/examples/services/mariadb This example shows a Drone CI pipeline step that waits for MariaDB to initialize before attempting to connect. It includes a 'sleep' command to allow the database sufficient time to start, followed by a connection attempt using the correct hostname. ```yaml kind: pipeline name: default steps: - name: test image: mariadb commands: - sleep 15 - mysql -u root -h database ``` -------------------------------- ### Drone CI Pipeline Configuration Example Source: https://docs.drone.io/pipeline/macstadium/syntax/parallelism This example demonstrates a basic Drone CI pipeline configuration using YAML. It defines a pipeline named 'default' of type 'macstadium' with three steps: 'backend', 'frontend', and 'publish'. The 'backend' and 'frontend' steps execute build and test commands respectively. The 'publish' step depends on the completion of both 'backend' and 'frontend' steps, and includes Docker build and push commands. ```yaml kind: pipeline type: macstadium name: default steps: - name: backend commands: - go build - go test - name: frontend commands: - npm install - npm test - name: publish commands: - docker build -t hello-world . - docker push hello-world depends_on: - frontend - backend ``` -------------------------------- ### Build Go Binary for Plugin Source: https://docs.drone.io/plugins/tutorials/golang This command compiles the Go program into a static binary for the Linux amd64 platform, suitable for containerization. It uses environment variables to set the target operating system and architecture, and disables CGO for a smaller, more portable binary. ```shell GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o webhook ``` -------------------------------- ### MongoDB Initialization Wait Command Source: https://docs.drone.io/pipeline/docker/examples/services/mongo This example demonstrates a command within a Drone CI pipeline step that waits for 5 seconds before attempting to connect to a MongoDB instance. This is often necessary to allow the MongoDB service container sufficient time to initialize and start accepting connections. ```bash sleep 5 mongo --host localhost --eval "db.version()" ``` -------------------------------- ### Kubernetes Pipeline Configuration Example Source: https://docs.drone.io/pipeline/kubernetes/overview This example demonstrates a basic Kubernetes pipeline configuration. It specifies the pipeline type as 'kubernetes' and defines a single step named 'greeting' that executes Go build and test commands within a golang:1.12 Docker image. ```yaml kind: pipeline type: kubernetes name: default steps: - name: greeting image: golang:1.12 commands: - go build - go test ``` -------------------------------- ### Configure Docker Pipeline (.drone.yml) Source: https://docs.drone.io/quickstart/docker Defines a default Docker pipeline named 'default'. It includes a single step named 'greeting' that uses the 'alpine' Docker image to execute 'echo hello' and 'echo world' commands. ```yaml kind: pipeline type: docker name: default steps: - name: greeting image: alpine commands: - echo hello - echo world ``` -------------------------------- ### Download Specific macOS Installer Source: https://docs.drone.io/runner/vm/drivers/anka Fetches a specific full installer version of macOS, in this case, version 12.2.1. ```shell softwareupdate --fetch-full-installer --full-installer-version 12.2.1 ``` -------------------------------- ### Docker Plugin Configuration Example Source: https://docs.drone.io/plugins/overview This example demonstrates the configuration settings for the Docker plugin within a Drone CI pipeline. It specifies parameters like username, password, repository, and tags. ```yaml - name: publish image: plugins/docker settings: username: kevinbacon password: pa55word repo: foo/bar tags: - 1.0.0 - 1.0 ``` -------------------------------- ### Example Drone CI Pipeline Configuration Source: https://docs.drone.io/plugins This snippet shows a complete Drone CI pipeline configuration using Docker and Slack plugins. It defines build, publish, and notify steps, demonstrating how to specify images and settings for each step. ```yaml kind: pipeline type: docker name: default steps: - name: build image: golang commands: - go get - go test - go build - name: publish image: plugins/docker settings: username: kevinbacon password: pa55word repo: foo/bar tags: - 1.0.0 - 1.0 - name: notify image: plugins/slack settings: channel: developers username: drone ``` -------------------------------- ### Drone Pipeline Configuration Example Source: https://docs.drone.io/pipeline/macstadium/syntax/trigger A basic Drone CI pipeline configuration for a MacStadium runner, including a build step with go build and go test commands, and a trigger limited to the 'master' branch. ```yaml kind: pipeline type: macstadium name: default steps: - name: build commands: - go build - go test trigger: branch: - master ``` -------------------------------- ### Run Drone Server Docker Container Source: https://docs.drone.io/server/provider/github-enterprise This command starts the Drone server as a Docker container, configuring it with essential environment variables for GitHub Enterprise integration, including server address, OAuth credentials, RPC secret, and network settings. It maps persistent data to a volume and publishes ports for external access. ```bash docker run \ --volume=/var/lib/drone:/data \ --env=DRONE_GITHUB_SERVER=https://github.com \ --env=DRONE_GITHUB_CLIENT_ID=05136e57d80189bef462 \ --env=DRONE_GITHUB_CLIENT_SECRET=7c229228a77d2cbddaa61ddc78d45e \ --env=DRONE_RPC_SECRET=super-duper-secret \ --env=DRONE_SERVER_HOST=drone.company.com \ --env=DRONE_SERVER_PROTO=https \ --publish=80:80 \ --publish=443:443 \ --restart=always \ --detach=true \ --name=drone \ drone/drone:2 ``` -------------------------------- ### Test Connection to Elasticsearch Service in Drone CI Source: https://docs.drone.io/pipeline/docker/examples/services/elasticsearch This example demonstrates a basic test step within a Drone CI pipeline. It uses an Alpine Linux image, installs the `curl` utility, and then attempts to connect to an Elasticsearch service named 'database' on the default port 9200. This is typically used to verify that the service container has started and is accessible. ```bash apk add curl sleep 45 curl http://database:9200 ``` -------------------------------- ### Build and Push Docker Plugin Image Source: https://docs.drone.io/plugins/tutorials/golang These shell commands build the Docker image for the webhook plugin using the Dockerfile and then push the image to a Docker registry. This makes the plugin available for use in Drone CI pipelines. ```shell $ docker build -t acme/webhook . $ docker push acme/webhook ``` -------------------------------- ### Install Tmux using Homebrew Source: https://docs.drone.io/runner/vm/drivers/anka This command installs the tmux terminal multiplexer using the Homebrew package manager. Tmux is used to manage the runner process. ```bash brew install tmux ``` -------------------------------- ### Define a Docker Pipeline with Build and Test Steps Source: https://docs.drone.io/pipeline/docker/syntax/steps This snippet shows a basic Drone CI pipeline configuration using Docker. It defines two steps: 'backend' which builds a Go application, and 'frontend' which installs Node.js dependencies and runs tests. ```yaml kind: pipeline type: docker name: default steps: - name: backend image: golang commands: - go build - go test - name: frontend image: node commands: - npm install - npm test ``` -------------------------------- ### Drone API Example Request with Authorization Source: https://docs.drone.io/api/overview This example demonstrates how to make a GET request to the Drone API's user endpoint, including the necessary Authorization header for authentication. ```bash curl -X GET "http://localhost:8080/api/user" \ -H "Authorization: Bearer AKIAIOSFODNN7EXAMPLE" ``` -------------------------------- ### Docker Plugin Configuration Example Source: https://docs.drone.io/plugins This example demonstrates the configuration settings for the Docker plugin within a Drone CI pipeline. It specifies parameters like username, password, repository, and tags. ```yaml - name: publish image: plugins/docker settings: username: kevinbacon password: pa55word repo: foo/bar tags: - 1.0.0 - 1.0 ``` -------------------------------- ### Execute Drone CI Plugin Locally Source: https://docs.drone.io/plugins/tutorials/golang This command demonstrates how to run the built webhook plugin locally using Docker. It passes the necessary configuration parameters (URL, method, body) as environment variables to the container, simulating how Drone CI would execute the plugin. ```shell $ docker run --rm \ -e PLUGIN_METHOD=post \ -e PLUGIN_URL=http://hook.acme.com \ -e PLUGIN_BODY=hello \ acme/webhook ``` -------------------------------- ### Pull Drone Docker Image Source: https://docs.drone.io/server/provider/github-enterprise This command pulls the latest version of the Drone server Docker image from DockerHub. It ensures you have the most recent stable release for your installation. ```bash $ docker pull drone/drone:2 ``` -------------------------------- ### AWS Windows Pipeline Configuration Example Source: https://docs.drone.io/pipeline/aws/overview This example shows an AWS pipeline configured to run on a Windows 2019 EC2 instance. It includes a step to check the installation log file. ```yaml kind: pipeline type: vm name: default pool: use: windows-2019 steps: - name: check install commands: - type C:\ProgramData\Amazon\EC2-Windows\Launch\Log\UserdataExecution.log ... ``` -------------------------------- ### Go Pipeline: Test Multiple Architectures (YAML) Source: https://docs.drone.io/pipeline/docker/examples/languages/golang_gopath Shows how to use Drone's multi-pipeline feature to test a Go project on different architectures (e.g., amd64 and arm64) by defining separate pipeline configurations with platform specifications. ```yaml --- kind: pipeline name: test-on-amd64 platform: arch: amd64 steps: - name: test image: golang commands: - go get - go test --- kind: pipeline name: test-on-arm64 platform: arch: arm64 steps: - name: test image: golang commands: - go get - go test ... ``` -------------------------------- ### Dockerfile for Drone Webhook Plugin Source: https://docs.drone.io/plugins/tutorials/bash This Dockerfile sets up an Alpine Linux environment, adds a shell script as the main entrypoint, and installs `curl`. It prepares the image to function as a Drone webhook plugin. ```dockerfile FROM alpine ADD script.sh /bin/ RUN chmod +x /bin/script.sh RUN apk -Uuv add curl ca-certificates ENTRYPOINT /bin/script.sh ```