Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env groovy
- def call(String project, String env, String area, String feature, String suite) {
- def container = "${project}_${new Random().nextInt(100000)}"
- def url = ""
- def command = ""
- def platform = ""
- def chunks = 10
- switch (project) {
- case 'launcher':
- url = "https://${(feature == "develop") ? "" : feature + "-"}launcher.${(env == "qa") ? "test" : ""}4game.com"
- if(feature == "live")
- url = "https://launcher.${area}.4game.com"
- command = "test:multiple:${(env == "qa") ? "qa" : "live"}"
- chunks = "${(env == "qa") ? 10 : 4}"
- platform = "${project}-${env}-${feature}-ru"
- break
- case 'web':
- if(env == "qa")
- url = "https://${area}-www.test4game.com"
- else url = "https://${feature}-${area}.4game.com"
- if(env != "qa" && area == "br")
- url = "https://br.4game.com"
- command = "test:multiple:web:${suite}"
- chunks = "${(env == "qa") ? 20 : 4}"
- platform = "${project}-${env}-${feature}-${area}"
- break
- case 'carrier':
- url = "https://carrier.test4game.com"
- "https://${(feature == "develop") ? "" : feature + "-"}carrier.${(env == "qa") ? "test" : ""}4game.com"
- command = "test:multiple:${(env == "qa") ? "qa" : "live"}"
- break
- }
- try {
- if(project != "web" && (project == "launcher" && feature == "develop" && env != "production")) {
- sh script: "docker build tests -t ${container}"
- sh script: "docker rmi docker-registry.inn.ru/forgame/4game-ui-tests:latest || true"
- sh script: "docker tag ${container} docker-registry.inn.ru/forgame/4game-ui-tests:latest"
- sh script: "docker push docker-registry.inn.ru/forgame/4game-ui-tests:latest"
- sh script: "docker run --shm-size=4096M -e 'BASE_URL=${url}' -e 'PLATFORM=${platform}' -e 'CHUNKS=${chunks}' --name ${container} ${container} -c 'npm run ${command}'"
- }
- else {
- sh script: "docker run --shm-size=4096M -e 'BASE_URL=${url}' -e 'PLATFORM=${platform}' -e 'CHUNKS=${chunks}' --name ${container} docker-registry.inn.ru/forgame/4game-ui-tests:latest -c 'npm run ${command}'"
- }
- }
- finally {
- sh script: "docker cp ${container}:/app/output output_${container} || true"
- sh script: "docker rm ${container} || true"
- sh script: "docker rmi ${container} || true"
- sh script: "mkdir allure-results || true"
- sh script: "find output_${container} -type f -name '*.xml' -exec cp -t allure-results '{}' \\; || true"
- sh script: "find output_${container} -type f -name '*.png' -exec cp -t allure-results '{}' \\; || true"
- sh script: "echo 'URL=${url}\r\nPROJECT=${project}\r\nENV=${env}\r\nFEATURE=${feature}\r\nAREA=${area}' > allure-results/environment.properties"
- allure results: [[path: 'allure-report']]
- slackNotify()
- cleanWs()
- }
- }
- @NonCPS
- void slackNotify() {
- String color
- String channel = '#ui-tests-notify'
- if(currentBuild.result == null) {
- if(currentBuild.id == '1'){
- color = 'blue'
- }
- else if(currentBuild.previousBuild.result == 'SUCCESS'){
- color = 'good'
- }
- else {
- color = 'danger'
- }
- started = "Build started"
- slackSend channel: channel, failOnError: true, color: color, message: "${env.JOB_NAME} - ${env.BUILD_DISPLAY_NAME}\n ${started} (<${env.BUILD_URL}|Open>)"
- }
- else if(currentBuild.result == 'SUCCESS'){
- color = 'good'
- slackSend channel: channel, failOnError: true, color: color, message: "${env.JOB_NAME} - ${env.BUILD_DISPLAY_NAME} \n *${currentBuild.result}* (<${env.BUILD_URL}|Open>)"
- }
- else {
- color = 'danger'
- slackSend channel: channel, failOnError: true, color: color, message: "${env.JOB_NAME} - ${env.BUILD_DISPLAY_NAME} \n *${currentBuild.result}* (<${env.BUILD_URL}|Open>)"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement