Giter Site home page Giter Site logo

ondram / ci-detector-standalone Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 0.0 47 KB

Standalone CLI command to detect continuous integration server and provide unified access to properties of current build

License: MIT License

PHP 100.00%
continuous-integration standalone-library php

ci-detector-standalone's Introduction

CI Detector standalone command

Latest Stable Version Build Status Coverage Status

Standalone CLI command wrapper for ci-detector PHP library.

It is used to detect continuous integration environment and to provide a unified interface to read the build information. You can use the command to make your scripts (and especially CLI tools) portable for multiple build environments.

The detection is based on environment variables injected to the build environment by continuous integration server. However, these variables are named differently in each CI. This command is based on lightweight ci-detector PHP library, which provides adapter for each supported CI server.

If you need the detection inside PHP script (so you don't need the CLI command), you can just use directly the ci-detector library.

Releases are matched to the versions of the parent ci-detector library. See changelog there for the list of the latest changes.

Usage

$ ./ci-detector.phar # return status code 0 if CI detected, 1 otherwise
$ echo $? # to print status code of previous command
0

$ ./ci-detector.phar detect ci-name
Travis CI

$ ./ci-detector.phar detect build-number
11.3

$ ./ci-detector.phar detect build-url
https://travis-ci.org/OndraM/ci-detector-standalone/jobs/189809581

$ ./ci-detector.phar detect branch
feature/test

$ ./ci-detector.phar detect commit
f45e5809cefdbb819913f9357381f4d291fd49a9

$ ./ci-detector.phar detect repository-url # Not supported on Travis CI, will print empty string

$ ./ci-detector.phar detect is-pull-request
Yes

$ ./ci-detector.phar detect branch
main

See method reference for a documentation of each property.

Dump all available properties

dump command will show all properties detected in current environment by ci-detector:

$ ./ci-detector.phar dump
+-----------------+---------------------------------------------------------------+
| Property name   | Current value                                                 |
+-----------------+---------------------------------------------------------------+
| ci-name         | Travis CI                                                     |
| build-number    | 164.1                                                         |
| build-url       | https://travis-ci.org/OndraM/ci-detector-standalone/jobs/1337 |
| commit          | 9b232f6813915ddb1f226de93366cb924c72e400                      |
| branch          | feature/dump-command                                          |
| target-branch   | main                                                          |
| repository-name | ondram/ci-detector                                            |
| repository-url  | ssh://git@gitserver:7999/project/repo.git                     |
| is-pull-request | Yes                                                           |
+-----------------+---------------------------------------------------------------+

This is basically a table with output of describe() method of CiInterface (see method reference).

Installation

Install as a standalone PHAR file

CI Detector could be installed as a standalone executable PHAR file (ci-detector.phar). Download latest version from Releases page.

To run CI Detector use command ./ci-detector.phar in the directory where you saved the file (or php ci-detector.phar if the file itself is not executable).

Install using Composer

$ composer require ondram/ci-detector-standalone

To run CI Detector use command vendor/bin/ci-detector.

If you need the detection inside PHP script (and you don't need the CLI command), you can just use directly the lightweight ci-detector library.

ci-detector-standalone's People

Contributors

ondram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.