In Jenkins pipeline following error - com mysql cj jdbc exceptions CommunicationsException Communications link failure

0 votes
I have built a jenkins pipeline as below:
pipeline { agent any tools { maven 'Maven' }

environment {
    PROJECT_ID = 'onyx-sequence-334211'
            CLUSTER_NAME = 'k8s-cluster'
            LOCATION = 'us-central1-c'
            CREDENTIALS_ID = 'kubernetes'       
}

stages {
    stage('Scm Checkout') {
        steps {
            checkout scm
        }
    }
    
    stage('Build') {
        steps {
            sh 'mvn clean package'
        }
    }
    
    stage('Test') {
        steps {
            echo "Testing..."
            sh 'mvn test'
        }
    }
    
    stage('Build Docker Image') {
        steps {
            sh 'whoami'
            script {
                myimage = docker.build("justinmgeorgedocker/currexchange:${env.BUILD_ID}")
            }
        }
    }
    
    stage("Push Docker Image") {
        steps {
            script {
                echo "Push Docker Image"
                withCredentials([string(credentialsId: 'dockerhub', variable: 'dockerhub')]) {
                        sh "docker login -u justinmgeorgedocker -p ${dockerhub}"
                }
                    myimage.push("${env.BUILD_ID}")
                
            }
        }
    }
    
    stage('Deploy to K8s') {
        steps{
            echo "Deployment started ..."
            sh 'ls -ltr'
            sh 'pwd'
            sh "sed -i 's/tagversion/${env.BUILD_ID}/g' deployment.yaml"
            echo "Start deployment of deployment.yaml"
            step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'deployment.yaml', credentialsId: env.CREDENTIALS_ID, verifyDeployments: true])
            echo "Deployment Finished ..."
        }
    }
}
}
The spring boot application I am trying to deploy is connected to MySql db. While building in Jenkins I get following error in "Build" stage:

HikariPool-1 - Exception during pool initialization.

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) ~[mysql-connector-java-8.0.22.jar:8.0.22]

Do I need to configure/launch MySql as well fro Jenkins ? Could someone feedback on the same at the earliest ?

~ Joe
Dec 14, 2021 in Jenkins by justin

edited 4 days ago 19 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP