Search code examples
selenium-webdrivercontinuous-integrationjenkins-pipelineappium-android

Jenkin Pipeline stuck after sh command


I had created automation framework where selenium and appium android both are used , I had setup jenkins on aws ec2 ubuntu , I am using jenkin pipeline to run test

pipeline {
    agent any
    environment {
        APPIUM_PORT= 5555
    }
    stages {
        stage('Build') {
            steps {
                echo "GIT.."
                git credentialsId: 'gitHubCred', url: 'https://username_qa_automation.git'

            }
        }
        stage('Test') {
            steps {
                echo "Testing.."
                withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin']) {
                sh "appium --port ${APPIUM_PORT}"}
            }
        }
        stage('Run Test') {
            steps {
                echo "Running...."
                sh "mvn clean test -DsuiteXml=testng.xml -Denv=dev -Dbrowser=chrome -Dplatform=android"
            }
        }

        stage('Kill Appium') {
              steps {
                always{
                   echo "Stop appium server"
                     sh "kill \$(lsof -t -i :${APPIUM_PORT})"
                      }
                    }
                }
    }
}

When I run build , at console its just stop forever , does not move further , what wrong I am doing here , I am trying this for first time

+ appium --port 5555
[35m[Appium][39m Welcome to Appium v1.21.0
[35m[Appium][39m Non-default server args:
[35m[Appium][39m   port: 5555
[35m[Appium][39m Appium REST http interface listener started on 0.0.0.0:5555

Solution

  • Use & run appium in background so it will move to next command after starting appium server

    i.e, sh "appium --port ${APPIUM_PORT}&"}