Skip to content

🤖 A gradle plugin that checks if it is running on a continuous integration server and gives you access to the build metadata.

License

Notifications You must be signed in to change notification settings

vierbergenlars/ci-detect-gradle-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI detect plugin

CI Quality Gate Status Gradle Plugin Portal

A gradle plugin that checks if it is running on a continuous integration platform and gives you access to the build metadata.

Installation

plugins {
    // Check https://plugins.gradle.org/plugin/be.vbgn.ci-detect for the latest version
    id "be.vbgn.ci-detect" version "0.1.0"
}

Usage

This plugin gives you easy and consistent access to environment variables that CI platforms automatically add, independent of which CI solution you are using.

CI build metadata is exposed through the ci variable in your build.gradle. It can also be used programmatically from other Gradle plugins or code.

// Basic information
ci.isCi() // => true or false, depending on if you are running in a CI server or not
ci.reference // The current branch or tag that is being built

// Branch builds
ci.branch // The current branch that is being built

// Pull requests
ci.isPullRequest() // => true/false
ci.pullRequest // Pull request identifier (usually a string containing a number, depends on your SCM system)
ci.pullRequestTargetBranch // Branch where the pullrequest will be merged into

// Tags
ci.isTag() //  => true/false, depending on if this is a git tag that is being built or not
ci.tag // The tag name that is being built

// Platform information
ci.platform // => A string identifying the platform the build is run on.

Supported CI platforms:

Programmatic usage

import be.vbgn.gradle.cidetect.CiInformation;

CiInformation ci = CiInformation.detect(); // Attempts to detect CI from environment variables
CiInformation ci = CIInformation.detect(project); // Gives CI detectors access to the gradle Project variable, which may be used by detectors to extract additional information

Extending

You can provide extra CI detectors by creating a provider extending be.vbgn.gradle.cidetect.provider.CiInformationProvider.

There are 2 ways to register extra CI detectors:

  • Using the ServiceLoader mechanism: registering it as a service and placing your jar on the classpath.
  • Calling CiInformationProvider#registerProvider() from a separate Gradle plugin that is applied before be.vbgn.ci-detect.

For examples of providers, you can have a look at the builtin providers.

Development

Creating a release

Every git tag is automatically published to the gradle plugins repository by Travis-CI.

This plugin follows SemVer and tags are managed with Reckon.

To create a release from a commit, use ./gradlew reckonTagPush -Preckon.scope=patch -Preckon.stage=final to create a new patch release.

Tests are required to pass before a new release can be tagged.

About

🤖 A gradle plugin that checks if it is running on a continuous integration server and gives you access to the build metadata.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages