【问题标题】:docker exec -t container_name takes very long time in Jenkins pipelinedocker exec -t container_name 在 Jenkins 管道中需要很长时间
【发布时间】:2022-01-01 09:18:46
【问题描述】:

我正在为我的 dockerized Vue 应用程序创建一个新的 Jenkins 管道。

这是我的jenkinsfile 内容

#!groovy

pipeline {
    agent any

    stages {
        stage('Checkout') {
            steps {
                echo 'Checking out the PR'
                checkout scm
            }
        }

        stage('Build') {
            steps {
                echo 'Destroy Old Build'
                sh 'make destroy'
                echo 'Building'
                sh 'make exec'
                sh 'npm run build'
            }
        }

        stage('Test') {
            steps {
                echo 'Running Tests'
                sh 'make exec'
                sh 'unset DISPLAY'
                sh 'npm run test:e2e'
            }
        }

        stage('Destroy') {
            steps {
                echo 'Destroy Build'
                sh 'make destroy'
            }
        }
    }
}

这是我的Makefile

up:
    docker-compose -f docker-compose.local.yml up

build:
    docker-compose -f docker-compose.local.yml build

upbuild_d:
    docker-compose -f docker-compose.local.yml up -d --build

exec:
    docker-compose -f docker-compose.local.yml up -d --build && docker exec -t merchant-dashboard bash

test-e2e:
    docker-compose -f docker-compose.local.yml run frontend npm run test:e2e

destroy:
    docker-compose -f docker-compose.local.yml down -v

Build 阶段执行 make exec 时,在 jenkins 上完成阶段需要很长时间,直到我失去希望并中止运行。

知道为什么会发生这个问题,因为在我的本地机器上一切正常。

【问题讨论】:

  • Jenkins box 资源够不够?
  • @AKK 应该是的,但我不知道如何检查它,因为我是 jenkins 的新手

标签: jenkins docker-compose jenkins-pipeline docker-exec


【解决方案1】:

我的问题在于这个命令docker-compose -f docker-compose.local.yml up -d --build && docker exec -t merchant-dashboard bash

我是这样修复的 docker-compose -f docker-compose.local.yml up -d --build && docker exec merchant-dashboard bash -c 'npm run serve &'

参考"docker exec container bash" not working in jenkins

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-09-28
    • 1970-01-01
    • 2019-05-05
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 2021-08-07
    • 1970-01-01
    相关资源
    最近更新 更多