gkampitakis / ciinfo

Get details about the current Continuous Intergration environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:MIT License


Languages

Language:Go 97.0%Language:Makefile 3.0%