Home

Awesome

CI Info

Acknowledgement

This repository is based on work done in watson/ci-info and the contributors.

I will do my best to keep this library up to date and in sync with changes in watson/ci-info.


Get details about the current Continuous Integration environment.

Tests

Installation

go get github.com/gkampitakis/ciinfo

Usage

import (
  "fmt"

  "github.com/gkampitakis/ciinfo"
)

if ciinfo.IsCI {
  fmt.Printf("The name of the CI server is: %s", ciinfo.Name)
} else {
  fmt.Printf("This program is not running on a CI server")
}

CLI Support

ciinfo can also be used as a CLI. You can install it with

go install github.com/gkampitakis/ciinfo/ciinfo@latest

Then ciinfo command will be successful ( code 0 ) if running on CI else error ( code -1 ).

#  will output isCI if running onCI
ciinfo && echo 'isCI'

ciinfo also has

Usage of ciinfo:
  -output string
    	you can output info [json, pretty].
  -pr
    	check if shell is running on CI for a Pull Request.

Supported CI tools

Officially supported CI servers:

NameConstantisPR
Agola CIci.AGOLA
AWS CodeBuildciinfo.CODEBUILD
AppVeyorciinfo.APPVEYOR
Azure Pipelinesciinfo.AZURE_PIPELINES
Appcircleciinfo.APPCIRCLE
Bamboo by Atlassianciinfo.BAMBOO🚫
Bitbucket Pipelinesciinfo.BITBUCKET
Bitriseciinfo.BITRISE
Buddyciinfo.BUDDY
Buildkiteciinfo.BUILDKITE
CircleCIciinfo.CIRCLE
Cirrus CIciinfo.CIRRUS
Codefreshciinfo.CODEFRESH
Codeshipciinfo.CODESHIP🚫
Droneciinfo.DRONE
dsariciinfo.DSARI🚫
Earthly CIci.EARTHLY🚫
Expo Application Servicesciinfo.EAS🚫
Gerrit CIciinfo.GERRIT🚫
GitHub Actionsciinfo.GITHUB_ACTIONS
GitLab CIciinfo.GITLAB
Gitea Actionsci.GITEA_ACTIONS🚫
GoCDciinfo.GOCD🚫
Google Cloud Buildciinfo.GOOGLE_CLOUD_BUILD🚫
Harness CIciinfo.HARNESS🚫
Herokuciinfo.HEROKU🚫
Hudsonciinfo.HUDSON🚫
Jenkins CIciinfo.JENKINS
LayerCIciinfo.LAYERCI
Magnum CIciinfo.MAGNUM🚫
Netlify CIciinfo.NETLIFY
Nevercodeciinfo.NEVERCODE
Prowci.PROW🚫
ReleaseHubciinfo.RELEASEHUB
Renderciinfo.RENDER
Sail CIciinfo.SAIL
Screwdriverciinfo.SCREWDRIVER
Semaphoreciinfo.SEMAPHORE
Sourcehutciinfo.SOURCEHUT🚫
Strider CDciinfo.STRIDER🚫
TaskClusterciinfo.TASKCLUSTER🚫
TeamCity by JetBrainsciinfo.TEAMCITY🚫
Travis CIciinfo.TRAVIS
Velaci.VELA
Vercelciinfo.VERCEL
Visual Studio App Centerciinfo.APPCENTER🚫
Woodpeckerciinfo.WOODPECKER

API

ciinfo.Name

Returns a string containing name of the CI server the code is running on. If CI server is not detected, it returns empty string "".

Don't depend on the value of this string not to change for a specific vendor. If you find your self writing ciinfo.Name === "Travis CI", you most likely want to use ciinfo.IsVendor("TRAVIS") instead.

ciinfo.IsCI

Returns a boolean. Will be true if the code is running on a CI server, otherwise false.

Some CI servers not listed here might still trigger the ciinfo.isCI boolean to be set to true if they use certain vendor neutral environment variables. In those cases ciinfo.Name will be "" and no vendor specific boolean will be set to true.

ciinfo.IsPR

Returns a boolean if PR detection is supported for the current CI server. Will be true if a PR is being tested, otherwise false. If PR detection is not supported for the current CI server, the value will be false.

ciinfo.<VENDOR-CONSTANT>

A vendor specific boolean constant is exposed for each support CI vendor. A constant will be true if the code is determined to run on the given CI server, otherwise false.

Examples of vendor constants are ciinfo.TRAVIS or ciinfo.APPVEYOR. For a complete list, see the support table above.