Skip to content

swellaby/ci-detective

Repository files navigation

ci-detective

Simple utility to detect whether you are running in a CI server/environment

Latest Release GoDoc License Badge

Linux CI Badge Mac CI Badge Windows CI Badge

Go Report Card Test Results Badge Codecov Badge Sonar Quality Gate Badge


Installation

ci-detective is available as both an executable/cli and a package/api.

Grab a binary release or use go get:

go get -u github.com/swellaby/ci-detective

If you want to consume the package/api programmatically, just add the package import:

import (
    "github.com/swellaby/ci-detective/cidetective"
)

Usage

CLI

To use ci-detective as a CLI simply run the command:

ci-detective

The CLI will return an exit code of Zero if it detects the current environment is a CI engine/server. Otherwise it will return a non-Zero exit code.

Lib

The cidetective package exposes a single function: IsCI that returns a boolean indicating whether or not the current environment is a CI server/engine.

package main

import (
    "fmt"
    "github.com/swellaby/ci-detective/cidetective"
)

func main() {
    if cidetective.IsCI() {
        fmt.Println("Running in a CI environment!")
    } else {
        fmt.Println("Nope, this is NOT a CI environment!")
    }
}

Generator

Initially created by this swell generator!

Supported CIs