rfussien/gitlab2rundeck-adapter

This package is abandoned and no longer maintained. No replacement package was suggested.

a small gitlab to rundeck adapter

v1.1.3 2017-06-22 16:06 UTC

This package is auto-updated.

Last update: 2023-08-23 20:12:06 UTC


README

Latest Stable Version License Build Status Dependency Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

This package allows to run a rundeck job after a gitlab(ci) event is hooked.

Requirements:

  • works with PHP 5.6 or above
  • rundeck api 12 and above
  • gitlab(ci) 8.5 and above

note: it works with the webhook of gitlab AND gitlabCI. However, when using the webhook of gitlab, the build_status is considered as failed. So in that case it would be useful to specify "runOnFail: true" in the project config.

Install

Via Composer

$ composer require rfussien/gitlab2rundeck-adapter

Usage

Configuration

Create two yaml configuration files. One for rundeck and another one for the gitlab's projects

Rundeck configuration

# rundeck api configuration
# http{$ssl}://{$host}:{$port}/api/{api_version}/{jobID}/(run|executions)
host: rundeck.local                     # REQUIRED
token: CmBl3gDr8ua6uMXQS0pLSmGUDvHjdOl7 # REQUIRED
port: 4440                              # OPTIONAL (Default 4440)
ssl: true                               # OPTIONAL (Default false)
api_version: 13                         # OPTIONAL (Default 13. Has to be >= 12)
log_level: DEBUG                        # OPTIONAL ('DEBUG','VERBOSE','INFO','WARN','ERROR')

Gitlab projects configuration

# gitlab(ci) configuration
gitlab_url: http://gitlab
projects:
- project:
    name: repos/app1                             # REQUIRED project name (w/o the base_url)
    jobId: 558d3c76-7768-4056-a10c-0842ecae0ca9 # REQUIRED Rundeck Job UUID
    ref: master                                 # OPTIONAL default: master. Project branch
    runOnFail: true                             # OPTIONAL default: false. Run the job even if the tests failed
    runOnTagOnly: true                          # OPTIONAL default: false. Run the job only when a tag is done (useful for release deployment)
    jobArgs: { arg1: foo, arg2: bar }           # OPTIONAL Rundeck Job arguments
    runJobAs: foo                               # OPTIONAL Run the job as the given user
- project:
    name: repos/app2
    jobId: 558d3c76-7768-4056-a10c-0842ecae0ca8
    ref: master
    runOnFail: false
[...]

Run the adapter

$adapter = G2R\Adapter::factory(
    __DIR__ . '/rundeck.yml',
    __DIR__ . '/projects.yml',
    // Eventually, give it a logger that implements psr3 (Psr\Log\LoggerInterface)
    (new Monolog\Logger('g2r'))->pushHandler(new Monolog\Handler\StreamHandler('./g2r.log'))
);

$adapter->run();

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.