4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

気楽にJenkinsfileをLintしたい

Posted at

要約

jflintを使うと手元ですばやくJenkinsfileのLintができて便利

イントロ 

 Pipelineのジョブを調整するにあたって、Jenkinsfileの編集時はgroovyベースのDSLで書いてあることや時々しか触らないこともあって、動くまでエラーが発生しがちです。

動かすためにJenkinsfileを編集した後リモートブランチにpushしてまわすのは大変です。Replay機能を使ってGUIで変更して実行するのは少し速いですが、むやみにビルド記録が増えるのもできれば避けておきたいところです。

  最近またJenkinsfileをいじることが増えたので、Lintを簡単にできるというツールが発表されていたのを思い出しました。

jflint

Jenkinsfileのlintで救える命がある

作者の方のjflint紹介記事

インストール

インストール
npm install jflint -g
lint実行
jflint -j [Jenkins master hostname] Jenkinsfile

なるほど、確かにJenkinsのプラグイン公式のsshやcurlを使う方法より簡単そうなインターフェースです。

正しいJenkinsfileのLint実行例
% jflint --csrf-disabled -j http://jenkins.example.jp ~/project/Example/Jenkinsfile
Jenkinsfile successfully validated.
間違ったJenkinsfileをLintに掛けた場合
% jflint --csrf-disabled -j http://jenkins.example.jp ~/project/Example/Jenkinsfile
Errors encountered validating Jenkinsfile:
WorkflowScript: 98: unexpected token: } @ line 98, column 1.
   }
   ^

すぐに結果が返って来ました。これは役立ちそうです。

4
1
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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?