Oleksii Zhurba | 71e9788 | 2018-02-16 20:09:43 -0600 | [diff] [blame] | 1 | /** |
| 2 | * |
| 3 | * Launch pytest frameworks in Jenkins |
| 4 | * |
| 5 | * Expected parameters: |
| 6 | * SALT_MASTER_URL URL of Salt master |
| 7 | * SALT_MASTER_CREDENTIALS Credentials to the Salt API |
| 8 | * |
| 9 | * TESTS_SET Leave empty for full run or choose a file (test) |
| 10 | * TESTS_REPO Repo to clone |
| 11 | * TESTS_SETTINGS Additional environment varibales to apply |
| 12 | * PROXY Proxy to use for cloning repo or for pip |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | validate = new com.mirantis.mcp.Validate() |
| 17 | |
| 18 | def artifacts_dir = 'validation_artifacts/' |
| 19 | |
| 20 | node() { |
| 21 | try{ |
| 22 | stage('Initialization') { |
| 23 | validate.prepareVenv(TESTS_REPO, PROXY) |
| 24 | } |
| 25 | |
| 26 | stage('Run Tests') { |
| 27 | sh "mkdir -p ${artifacts_dir}" |
| 28 | validate.runTests(SALT_MASTER_URL, SALT_MASTER_CREDENTIALS, TESTS_SET, artifacts_dir, TESTS_SETTINGS) |
| 29 | } |
| 30 | stage ('Publish results') { |
| 31 | archiveArtifacts artifacts: "${artifacts_dir}/*" |
| 32 | junit "${artifacts_dir}/*.xml" |
| 33 | } |
| 34 | } catch (Throwable e) { |
| 35 | // If there was an error or exception thrown, the build failed |
| 36 | currentBuild.result = "FAILURE" |
| 37 | throw e |
| 38 | } |
| 39 | } |