젠킨스에서 백엔드 프로젝트도, 프론트 프로젝트도 같은 에러가 나면서 빌드가 실패했다. 빌드로 개발중인 서버에 배포가 되어야 진행이 되는데, 여기서 문제가 발생하면서 모든 것이 막히게 된 상황이었다.
Jenkins에 대해 수정한 것은 전혀 없는 상황이었다. 단지 평소 하던대로 개발한 내용을 푸쉬하고 Jenkins에서 빌드 버튼을 눌러 빌드 명령어를 실행하였는데, 갑자기 이런 문제가 터진 것이었다.
error=0, Failed to exec spawn helper
문제의 핵심은 위의 메세지였다. Jenkins가 git 프로세스를 실행하려다 OS 차원에서 fork/exec 단게에서 실패한 것이다.
아무것도 안 건드렸어도 아래 상황 중 하나면 이런 에러가 뜰 수 있다고 한다.
프로세스 실행에 필요한 메모리/스레드 부족
리눅스에서 fork() 실패 시 이런 메시지가 나옵니다.
원인:
java.io.IOException: error=0, Failed to exec spawn helper: pid: 887899, exit value: 1
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
Caused: java.io.IOException: Cannot run program "git" (in directory "/var/lib/jenkins/caches/git-d09a7cd79cb123ea724a4331f9f6f532"): error=0, Failed to exec spawn helper: pid: 887899, exit value: 1
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:995)
at hudson.Launcher$ProcStarter.start(Launcher.java:507)
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2839)
Caused: hudson.plugins.git.GitException: Error performing git command: git init /var/lib/jenkins/caches/git-d09a7cd79cb123ea724a4331f9f6f532
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2862)
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2771)
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2766)
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:2059)
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:1083)
Caused: hudson.plugins.git.GitException: Could not init /var/lib/jenkins/caches/git-d09a7cd79cb123ea724a4331f9f6f532
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:1085)
at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.init(CliGitAPIImpl.java:365)
at PluginClassLoader for git-client//hudson.plugins.git.GitAPI.init(GitAPI.java:246)
at PluginClassLoader for git//jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:390)
Caused: java.io.IOException
at PluginClassLoader for git//jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:413)
at PluginClassLoader for scm-api//jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:219)
at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:120)
at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:72)
at PluginClassLoader for workflow-job//org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:316)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:446)
Finished: FAILURE
sudo systemctl restart jenkins
리소스가 비워져서 일시적으로 복구될 가능성 높음
근본 해결 위해선 ulimit 조정, 메모리 확보, git 경로/권한 점검 필요