mardi 22 septembre 2020

How to run Jenkins parallel cypress on different agents?

I'm running parallel cypress in Jenkins on the same slave, and it's working,

I want to change the agent of the inner parallel stages, how can I do it?

for example, run "cypress tester C" on slave-2.

this is my current Jenkinsfile:

pipeline {
options {
    timeout(time: 15, unit: 'MINUTES')
}
agent {
    docker {
        image 'cypress/base:12.18.2'
        label 'slave-1'
    }
}
parameters {
    string(defaultValue: 'master', description: 'Branch name', name: 'branchName')
}

stages {
    stage('build') {
        steps {
            echo 'Running build...'
            sh 'npm ci'
            sh 'npm run cy:verify'
        }
    }

    stage('cypress parallel tests') {
        environment {
            CYPRESS_RECORD_KEY = 'MY_CYPRESS_RECORD_KEY'
            CYPRESS_trashAssetsBeforeRuns = 'false'
        }
        parallel {
            stage('cypress tester A') {
                steps {
                    echo "Running build ${env.BUILD_ID}"
                    sh "npm run cypress:run"
                }
            }
            stage('cypress tester B') {
                steps {
                    echo "Running build ${env.BUILD_ID}"
                    sh "npm run cypress:run"
                }
            }
            stage('cypress tester C') {
                steps {
                    echo "Running build ${env.BUILD_ID}"
                    sh "npm run cypress:run"
                }
            }
        }

    }
}

post {
    always {
        cleanWs(deleteDirs: true)
        echo 'Tests are finished'
    }
}

}

The run command is:

cypress run --record --parallel --config videoUploadOnPasses=false --ci-build-id $BUILD_TAG

Aucun commentaire:

Enregistrer un commentaire