Simple utility to detect whether you are running in a CI server/environment
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"
)
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.
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!")
}
}
Initially created by this swell generator!