Jenkins のプラギンを作ってみたくなった

Android アプリ開発をやり初めてから Java にまた慣れてきたこともあって、今度は Jenkins の Plugin を作ってみたくなった。

Jenkins のプラグインを開発するためには何が必要か調べてみた。だいぶ前に調べたときは maven が必須だったはずだけど、いまは Gradle を使ってビルドできるそうだ。 具体的な方法はこの Wiki のページに書いてある。その内容を適当に訳したものを以下に書いておく。

必要条件

初期化

プラグイン用のプロジェクトディレクトリは、プラグイン名が foo だったら、foo または foo-plugin にする必要がある。そして、build.gradle に次の内容を書く:

apply from:"https://raw.github.com/jenkinsci/gradle-jpi-plugin/master/install"
// Or copy the contents of that URL into your build.gradle directly.

// Whatever other plugins you need to load.

groupId = "org.jenkins-ci.plugins"
version = "0.0.1-SNAPSHOT"    // Or whatever your version is.
description = "A description of your plugin"

jenkinsPlugin {
    coreVersion = '1.420'                                               // Version of Jenkins core this plugin depends on.
    displayName = 'Hello World plugin built with Gradle'                // Human-readable name of plugin.
    url = 'http://wiki.jenkins-ci.org/display/JENKINS/SomePluginPage'   // URL for plugin on Jenkins wiki or elsewhere.
    gitHubUrl = 'https://github.com/jenkinsci/some-plugin'              // Plugin URL on GitHub. Optional.

   // The developers section is optional, and corresponds to the POM developers section.
   developers {
       developer {
           id 'abayer'
           name 'Andrew Bayer'
           email 'andrew.bayer@gmail.com'
       }
   }                           

}

もし追加で必要なリポジトリが存在するなら、それを jenkinsPlugin セクションの後ろに追記する。

ビルド

gradle celan jpi を実行する。

テスト

リリース