A stage in pipeline having java.net.SocketTimeoutException: timeout error for rundeck server connection with child server

42 Views Asked by At

can anyone help me with exception I am getting for below Jenkins pipeline stage. below is the pipeline stage which connects to rundeck server and imports few config files to child servers. When pipeline is triggered, though config files are imported to the child server as rundeck connected to child server, pipeline is failing for java.net.SocketTimeoutException: timeout error. rundeck child servers are located in two different regions, SV and NL whereas NL region child servers are getting connected but one of child server from SV region is not getting connected immediately [rundeck server keeps trying to connect to child server]and because of which the exception occurs and the pipeline catching the exception and is failing. I have tried connecting rundeck main server to SV child server manually with ping command and ssh connection, which works well. But when the pipeline triggered, the exception occurs, and pipeline is failing. It would be a great help if any solution suggested.

stage('Send Webhook') {
          failFast true
          parallel {
                stage('NL region') {
                    agent { label 'il-octopus' }
                    environment {
                        RD_TOKEN = "${RD_TOKEN_NL}"
                        RD_URL = "${RD_URL_NL}"
                    }
                    steps {
                        script {
                            
                            try {
                                echo "in try code - NL"
                                def rdOutputNL = sh(script: "rd run -p STG --job Deployment/Core/Import --follow -- -version ${params.ReleaseVersion}", returnStdout: true).trim()  
                            }
                            catch (InterruptedException interruptedException) {
                                echo "Caught InterruptedException: ${interruptedException.message}"
                            } 
                            catch (Exception e) {
                                currentBuild.result = 'FAILURE'
                                env.BUILD_FAIL_REGION = "NL"
                                echo "in catch code"
                                log.error("Stage NL failed due to error occurrance")
                                throw e
                            }
                        }
                    }
                }

                stage('SV region') {
                    agent { label 'il-octopus' }
                    environment {
                        RD_TOKEN = "${RD_TOKEN_SV}"
                        RD_URL = "${RD_URL_SV}"
                    }
                    steps {
                        script {
                            try {
                                echo "in try code - SV"
                                def rdOutputSV = sh(script: "rd run -p STG --job Deployment/Core/Import --follow -- -version ${params.ReleaseVersion}", returnStdout: true).trim()
                            } 
                            catch (InterruptedException interruptedException) {
                                echo "Caught InterruptedException: ${interruptedException.message}"
                            } 
                            catch (Exception e) {
                                currentBuild.result = 'FAILURE'
                                env.BUILD_FAIL_REGION = "SV"
                                echo "in catch code"
                                log.error("Stage SV failed due to error occurrance")
                                throw e
                            }
                        }
                    }
                }
            }
            post{
                failure {
                    script {
                        echo "PROJECT: ${RD_PROJECT} and FAIL_REGION: ${env.BUILD_FAIL_REGION}"
                        if (env.BUILD_FAIL_REGION == "NL") {
                            log.error("Import failed to NL - region Rundeck - please login to Rundeck to see logs")
                            
                            
                        } else {
                            log.error("Import failed to SV - region Rundeck - please login to Rundeck to see logs")
                        }
                 
                    }
            
                }
            }
        

0

There are 0 best solutions below