LoginSignup
8
8

More than 5 years have passed since last update.

Jenkins ジョブのビルドパラメータを直近の日付選択リストにしたい

Last updated at Posted at 2014-10-12

定期実行してる処理を手動で再実行したいときとか、割とあるニーズかなあと思います。

利用するプラグイン

Dynamic Parameter Plug-in が適任かなと思いました。

文字列だったり、リストだったりのビルドパラメータをGroovyスクリプトで動的生成できるようになる。

Extensible Choice Parameter plugin でも良さそう。

プロジェクト設定

プロジェクト設定の This build is parameterized にチェック入れて、Dynamic Choice Parameter を選択。
Choices Script に値を返却するスクリプト書くだけ。

具体例: 直近3日の YYYYMMdd のリストが欲しい

use (groovy.time.TimeCategory) {
    def today = new Date()
    return (0..2).collect { i -> (today - i.days).format('YYYYMMdd') }
}

こんな感じで、下記のようなビルドパラメータのリストが利用できる。
(2014/10/12に実行した場合)

  • 20141012
  • 20141011
  • 20141010

お便利なプラグインですね。

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8