Skip to content

Get details about the current Continuous Intergration environment

License

Notifications You must be signed in to change notification settings

gkampitakis/ciinfo

Repository files navigation

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:

Name Constant isPR
Agola CI ci.AGOLA
AWS CodeBuild ciinfo.CODEBUILD
AppVeyor ciinfo.APPVEYOR
Azure Pipelines ciinfo.AZURE_PIPELINES
Appcircle ciinfo.APPCIRCLE
Bamboo by Atlassian ciinfo.BAMBOO 🚫
Bitbucket Pipelines ciinfo.BITBUCKET
Bitrise ciinfo.BITRISE
Buddy ciinfo.BUDDY
Buildkite ciinfo.BUILDKITE
CircleCI ciinfo.CIRCLE
Cirrus CI ciinfo.CIRRUS
Codefresh ciinfo.CODEFRESH
Codeship ciinfo.CODESHIP 🚫
Drone ciinfo.DRONE
dsari ciinfo.DSARI 🚫
Earthly CI ci.EARTHLY 🚫
Expo Application Services ciinfo.EAS 🚫
Gerrit CI ciinfo.GERRIT 🚫
GitHub Actions ciinfo.GITHUB_ACTIONS
GitLab CI ciinfo.GITLAB
Gitea Actions ci.GITEA_ACTIONS 🚫
GoCD ciinfo.GOCD 🚫
Google Cloud Build ciinfo.GOOGLE_CLOUD_BUILD 🚫
Harness CI ciinfo.HARNESS 🚫
Heroku ciinfo.HEROKU 🚫
Hudson ciinfo.HUDSON 🚫
Jenkins CI ciinfo.JENKINS
LayerCI ciinfo.LAYERCI
Magnum CI ciinfo.MAGNUM 🚫
Netlify CI ciinfo.NETLIFY
Nevercode ciinfo.NEVERCODE
Prow ci.PROW 🚫
ReleaseHub ciinfo.RELEASEHUB
Render ciinfo.RENDER
Sail CI ciinfo.SAIL
Screwdriver ciinfo.SCREWDRIVER
Semaphore ciinfo.SEMAPHORE
Sourcehut ciinfo.SOURCEHUT 🚫
Strider CD ciinfo.STRIDER 🚫
TaskCluster ciinfo.TASKCLUSTER 🚫
TeamCity by JetBrains ciinfo.TEAMCITY 🚫
Travis CI ciinfo.TRAVIS
Vela ci.VELA
Vercel ciinfo.VERCEL
Visual Studio App Center ciinfo.APPCENTER 🚫
Woodpecker ciinfo.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.

About

Get details about the current Continuous Intergration environment

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published