2017 © Pedro Peláez
 

library gitlab2rundeck-adapter

a small gitlab to rundeck adapter

image

rfussien/gitlab2rundeck-adapter

a small gitlab to rundeck adapter

  • Thursday, June 22, 2017
  • by rfussien
  • Repository
  • 2 Watchers
  • 3 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

gitlab2rundeck-adapter

Latest Stable Version License Build Status Dependency Status Code Coverage Scrutinizer Code Quality SensioLabsInsight, (*1)

This small package able you to run a rundeck job after a gitlab(ci) event is hooked., (*2)

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., (*3)

Install

Via Composer, (*4)

``` bash $ composer require rfussien/gitlab2rundeck-adapter, (*5)


## Usage ### Configuration Create two yaml configuration files. One for rundeck and another one for the gitlab's projects #### Rundeck configuration ```yaml # 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

bash $ composer test, (*6)

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*7)

Security

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

License

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

The Versions

12/07 2016