te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>Jenkins Pipeline: "process apparently never started" error during the Build stage in a Docker agent - Stack Ov
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Jenkins Pipeline: "process apparently never started" error during the Build stage in a Docker agent - Stack Ov

programmeradmin3浏览0评论

I am running a Jenkins on local and I created a pipeline that uses a Docker container as an agent for the build stage. However, I am encountering the following error during the Build and Test stage.

process apparently never started in /var/lib/jenkins/workspace/ci-cd-ec2@2@tmp/durable-72cb4860
(running Jenkins temporarily with -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)

I have created a jenkins user here is the terminal response

 uid=135(jenkins) gid=142(jenkins) groups=142(jenkins),998(docker)

Here is the Jenkins pipeline

pipeline {
    agent {
        docker {
            // Use a Docker image that has Maven, Java 21, and (optionally) Docker CLI installed.
            image 'jelastic/maven:3.9.5-openjdk-21'
            // Mount the host Docker socket so the container can run docker commands.
            args '--user root -v /var/run/docker.sock:/var/run/docker.sock'
        }
    }

    environment {
        // Define your Docker image name (update with your Docker Hub username and image name)
        DOCKER_IMAGE = "rajputuser/docker-shivam-imz:latest"
        // Set the SonarQube URL. Update this IP if needed.
        SONAR_URL = "http://172.17.0.2:9000"
    }

    stages {
        stage('Build and Test') {
            steps {
                // List files (for debugging) and run Maven to clean, compile, test, and package your app.
                sh 'ls -ltr'
                sh 'mvn clean package'
            }
        }

        stage('SonarQube Analysis') {
            steps {
                // Run SonarQube analysis using Maven.
                // Credentials for SonarQube are injected via SONAR_TOKEN.
                withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_TOKEN')]) {
                    sh 'mvn sonar:sonar -Dsonar.login=$SONAR_TOKEN -Dsonar.host.url=${SONAR_URL}'
                    echo 'SonarQube analysis completed successfully!'
                }
            }
        }

        stage('Build Docker Image') {
            agent {
                docker {
                  image 'abhishekf5/maven-abhishek-docker-agent:v1'
                  args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
                }
            }
            steps {
                // Build the Docker image using the Dockerfile in the workspace.
                sh 'docker build -t $DOCKER_IMAGE .'
            }
        }

        stage('Push Docker Image') {
            agent {
                docker {
                  image 'abhishekf5/maven-abhishek-docker-agent:v1'
                  args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
                }
            }
            steps {
                // Log in to Docker Hub and push the built image.
                withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
                    sh 'echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin'
                    sh 'docker push $DOCKER_IMAGE'
                }
            }
        }

        stage('Deploy to EC2') {
            agent {
                docker {
                    image 'abhishekf5/maven-abhishek-docker-agent:v1'
                     args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
                     }
            }
            steps {
                // Deploy to an EC2 instance via SSH.
                withCredentials([sshUserPrivateKey(credentialsId: '27727626-31a0-4d61-ab9d-18353c0d6b89', keyFileVariable: 'EC2_KEY', usernameVariable: 'EC2_USER')]) {
                    sh '''
                        ssh -o StrictHostKeyChecking=no -i $EC2_KEY [email protected] <<EOF
                        docker pull $DOCKER_IMAGE
                        docker stop springboot-app || true
                        docker rm springboot-app || true
                        docker run -d --name springboot-app -p 8081:8081 $DOCKER_IMAGE
                        EOF
                    '''
                }
            }
        }
    }

    post {
        always {
            cleanWs()  // Clean the workspace after the pipeline completes.
        }
    }
}

Verified that Jenkins has permission to access /var/run/docker.sock. Checked that the Docker image jelastic/maven:3.9.5-openjdk-21 is pulled correctly. Ensured Jenkins has sufficient resources (CPU, RAM, disk space). Tried adding -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true, but no additional logs appeared. Checked if running mvn clean package manually inside the same container works (it does). Restarted Jenkins and Docker service, but the issue persists.

I am running a Jenkins on local and I created a pipeline that uses a Docker container as an agent for the build stage. However, I am encountering the following error during the Build and Test stage.

process apparently never started in /var/lib/jenkins/workspace/ci-cd-ec2@2@tmp/durable-72cb4860
(running Jenkins temporarily with -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)

I have created a jenkins user here is the terminal response

 uid=135(jenkins) gid=142(jenkins) groups=142(jenkins),998(docker)

Here is the Jenkins pipeline

pipeline {
    agent {
        docker {
            // Use a Docker image that has Maven, Java 21, and (optionally) Docker CLI installed.
            image 'jelastic/maven:3.9.5-openjdk-21'
            // Mount the host Docker socket so the container can run docker commands.
            args '--user root -v /var/run/docker.sock:/var/run/docker.sock'
        }
    }

    environment {
        // Define your Docker image name (update with your Docker Hub username and image name)
        DOCKER_IMAGE = "rajputuser/docker-shivam-imz:latest"
        // Set the SonarQube URL. Update this IP if needed.
        SONAR_URL = "http://172.17.0.2:9000"
    }

    stages {
        stage('Build and Test') {
            steps {
                // List files (for debugging) and run Maven to clean, compile, test, and package your app.
                sh 'ls -ltr'
                sh 'mvn clean package'
            }
        }

        stage('SonarQube Analysis') {
            steps {
                // Run SonarQube analysis using Maven.
                // Credentials for SonarQube are injected via SONAR_TOKEN.
                withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_TOKEN')]) {
                    sh 'mvn sonar:sonar -Dsonar.login=$SONAR_TOKEN -Dsonar.host.url=${SONAR_URL}'
                    echo 'SonarQube analysis completed successfully!'
                }
            }
        }

        stage('Build Docker Image') {
            agent {
                docker {
                  image 'abhishekf5/maven-abhishek-docker-agent:v1'
                  args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
                }
            }
            steps {
                // Build the Docker image using the Dockerfile in the workspace.
                sh 'docker build -t $DOCKER_IMAGE .'
            }
        }

        stage('Push Docker Image') {
            agent {
                docker {
                  image 'abhishekf5/maven-abhishek-docker-agent:v1'
                  args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
                }
            }
            steps {
                // Log in to Docker Hub and push the built image.
                withCredentials([usernamePassword(credentialsId: 'dockerhub', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
                    sh 'echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin'
                    sh 'docker push $DOCKER_IMAGE'
                }
            }
        }

        stage('Deploy to EC2') {
            agent {
                docker {
                    image 'abhishekf5/maven-abhishek-docker-agent:v1'
                     args '--user root --privileged -v /var/run/docker.sock:/var/run/docker.sock' // mount Docker socket to access the host's Docker daemon
                     }
            }
            steps {
                // Deploy to an EC2 instance via SSH.
                withCredentials([sshUserPrivateKey(credentialsId: '27727626-31a0-4d61-ab9d-18353c0d6b89', keyFileVariable: 'EC2_KEY', usernameVariable: 'EC2_USER')]) {
                    sh '''
                        ssh -o StrictHostKeyChecking=no -i $EC2_KEY [email protected] <<EOF
                        docker pull $DOCKER_IMAGE
                        docker stop springboot-app || true
                        docker rm springboot-app || true
                        docker run -d --name springboot-app -p 8081:8081 $DOCKER_IMAGE
                        EOF
                    '''
                }
            }
        }
    }

    post {
        always {
            cleanWs()  // Clean the workspace after the pipeline completes.
        }
    }
}

Verified that Jenkins has permission to access /var/run/docker.sock. Checked that the Docker image jelastic/maven:3.9.5-openjdk-21 is pulled correctly. Ensured Jenkins has sufficient resources (CPU, RAM, disk space). Tried adding -D.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true, but no additional logs appeared. Checked if running mvn clean package manually inside the same container works (it does). Restarted Jenkins and Docker service, but the issue persists.

Share Improve this question asked 2 days ago Shivam KumarShivam Kumar 113 bronze badges 1
  • Here is the repo link github/kumarShivamCodes/pipeline-repo-springboot – Shivam Kumar Commented 2 days ago
Add a comment  | 

1 Answer 1

Reset to default 0

Check for Missing Dependencies

The container may lack required tools (bash, coreutils, procps):

docker run --rm -it jelastic/maven:3.9.5-openjdk-21 sh
apk add --no-cache bash coreutils procps

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论