簡體   English   中英

使用 Maven 和 npm 進程的 Jenkins 在 npm 安裝期間因 EAGAIN 錯誤而失敗

[英]Jenkins with Maven and npm process fails with EAGAIN error during npm install

所以我為一個使用 spring boot 作為后端和 vuejs 作為前端的應用程序設置了 jenkins 管道。 maven 構建過程首先構建前端,將其復制到后端,然后構建后端。 但是在前端的構建過程中,只有當我通過詹金斯管道運行它時,這個過程才會失敗。 (對於其他人來說,相同的管道顯然可以在不同的機器上工作)

[INFO] npm ERR! code EAGAIN
[INFO] npm ERR! syscall spawn sh
[INFO] npm ERR! path /var/lib/jenkins/workspace/pipeline/frontend/node_modules/pre-commit
[INFO] npm ERR! errno -11
[INFO] npm ERR! spawn sh EAGAIN
[INFO] npm ERR! command sh -c node install.js
[INFO] 
[INFO] npm ERR! A complete log of this run can be found in:
[INFO] npm ERR!     /var/lib/jenkins/.npm/_logs/2022-07-22T09_11_43_478Z-debug-0.log

日志的相關部分在這里: https ://pastebin.com/ewp6zRcv

詹金斯管道是:

pipeline {
    agent any

    parameters {
        gitParameter branchFilter: 'origin/(.*)', defaultValue: 'staging', name: 'BRANCH', type: 'PT_BRANCH'
    }

    tools {
        maven "Maven"
        nodejs "Node"
    }

    stages {
        stage('Build') {
            steps {
                // Get some code from a GitHub repository
                git branch: "${params.BRANCH}", url: 'https://github.com/TheExkaliburg/MoreFair'
             
                // Run Maven on a Unix agent.
                sh "mvn -Dmaven.test.failure.ignore=true clean package"
            }

            post {
                success {
                    archiveArtifacts 'target/*.jar'
                }
            }
        }
    }
}

jenkins 安裝在帶有 ubuntu 20.04 的 linux 服務器上,項目本身可以在https://github.com/TheExkaliburg/MoreFair上找到,並且要構建的分支正在暫存

奇怪的是,EAGAIN 失敗通常是“資源暫時不可用”。 失敗。 以 root 或 jenkins 用戶身份運行該進程可以正常工作,沒有任何錯誤,我有足夠的剩余磁盤空間,並且我的 ram 和 cpu 在構建過程中從未接近 100%

這也很奇怪,因為出現的錯誤並不總是相同的,fe

[INFO] -  Building for production...
[INFO] node[80787]: pthread_create: Resource temporarily unavailable
[INFO] node:events:505
[INFO]       throw er; // Unhandled 'error' event
[INFO]       ^
[INFO] 
[INFO] Error: spawn /var/lib/jenkins/workspace/MoreFairStaging/frontend/node/node EAGAIN
[INFO]     at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
[INFO]     at onErrorNT (node:internal/child_process:478:16)
[INFO]     at processTicksAndRejections (node:internal/process/task_queues:83:21)
[INFO] Emitted 'error' event on ChildProcess instance at:
[INFO]     at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
[INFO]     at onErrorNT (node:internal/child_process:478:16)
[INFO]     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
[INFO]   errno: -11,
[INFO]   code: 'EAGAIN',
[INFO]   syscall: 'spawn /var/lib/jenkins/workspace/MoreFairStaging/frontend/node/node',
[INFO]   path: '/var/lib/jenkins/workspace/MoreFairStaging/frontend/node/node',
[INFO]   spawnargs: [
[INFO]     '/var/lib/jenkins/workspace/MoreFairStaging/frontend/node_modules/thread-loader/dist/worker.js',
[INFO]     20
[INFO]   ]
[INFO] }

或者

[7,371s][warning][os,thread] Failed to start thread - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.

node 的版本是 16.16.0 和 npm 8.11; maven 在 3.8.6 上,java 17 用於 maven,java 11 用於 jenkins (2.346.2)

所以這個特定案例的問題是服務配置不允許產生更多任務

解決此問題的一種簡單方法(經過一周的研究並嘗試了各種事情)是systemctl edit jenkins並添加到配置中

[Service]
TaskMax=500

數字可能會有所不同,但您可以通過systemctl show --property=DefaultTasksMax找到默認值 165 還不夠

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM