概要
昨日まで問題なくJenkinsのビルドが動いていたのに、突然ビルドができなくなってしまいました。
ビルドのログを確認したところ、以下の様なエラーが発生していました。
> git.exe rev-parse --is-inside-work-tree # timeout=10
ERROR: Workspace has a .git repository, but it appears to be corrupt.
hudson.plugins.git.GitException: Command "git.exe rev-parse --is-inside-work-tree" returned status code 128:
stdout:
stderr: fatal: bad config line 1 in file .git/config
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1784)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1757)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1753)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1409)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1421)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.hasGitRepo(CliGitAPIImpl.java:196)
at hudson.plugins.git.GitAPI.hasGitRepo(GitAPI.java:232)
at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:185)
at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:214)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:247)
at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:75)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:215)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Creating git repository in C:\Program Files (x86)\Jenkins\caches\git-7dd8566e7a711901887efa9299fa2e2d
対処
ログに出力されていたパス(上記ログの最終行に出ています)を確認してみると、.git
ディレクトリがあり、エラーメッセージにあるようにconfigファイルがおかしなことになっていました。(テキストエディタで開けなくなっていました)
そこでcaches
ディレクトリ配下を一旦削除したところ、ビルド実行できるようになりました。
補足
問題となったジョブはMultibranch Pipeline
で構成しています。
定期的に対象リポジトリが更新されているかをチェックするようになっていますが、その処理でこけていたようです。