Mona101ma
Mona101ma

Reputation: 772

docker exec -t container_name takes very long time in Jenkins pipeline

I'm making a new Jenkins pipeline for my dockerized Vue application.

This is my jenkinsfile content

#!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'
            }
        }
    }
}

And this is my 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

While executing the make exec in Build stage, It takes a very long time without completing the stages on jenkins till I lose hope and abort the run. enter image description here

Any Idea why this problem happens as everything works fine on my local machine.

Upvotes: 1

Views: 555

Answers (1)

Mona101ma
Mona101ma

Reputation: 772

My problem here was in this command docker-compose -f docker-compose.local.yml up -d --build && docker exec -t my-container bash.

I fixed it that way docker-compose -f docker-compose.local.yml up -d --build && docker exec my-container bash -c 'npm run serve &'

Referring to "docker exec container bash" not working in jenkins

Upvotes: 1

Related Questions