Roman Lubianyi | 1ee6256 | 2021-11-08 15:05:45 +0200 | [diff] [blame] | 1 | salt = new com.mirantis.mk.Salt() |
| 2 | python = new com.mirantis.mk.Python() |
| 3 | common = new com.mirantis.mk.Common() |
| 4 | venvPepper = "venvPepper" |
| 5 | upgradeChecks = new com.mirantis.mcp.UpgradeChecks() |
| 6 | |
| 7 | reportDir = 'reportDir/' |
Oleksii Molchanov | 0f4d690 | 2023-01-11 11:19:01 +0200 | [diff] [blame] | 8 | waList =['check_34406', 'check_34645', 'check_35705', 'check_35884', 'check_36461', 'check_36461_2', 'check_36960', 'check_37068'] |
Roman Lubianyi | 1ee6256 | 2021-11-08 15:05:45 +0200 | [diff] [blame] | 9 | |
| 10 | timeout(time: PIPELINE_TIMEOUT, unit: 'HOURS') { |
| 11 | node('python') { |
| 12 | try { |
| 13 | python.setupPepperVirtualenv(venvPepper, SALT_MASTER_URL, SALT_MASTER_CREDENTIALS) |
| 14 | def clusterName = salt.getPillar(venvPepper, 'I@salt:master', "_param:cluster_name").get("return")[0].values()[0] |
| 15 | def reportContent = "" |
| 16 | stage('Start checking work-arounds') { |
| 17 | for (wa in waList) { |
| 18 | //false - return status of check, true - raise exception |
| 19 | def waData = upgradeChecks."$wa"(salt, venvPepper, clusterName, false) |
| 20 | def reportTemplate = """ |
| 21 | <tr> |
| 22 | <td class='row'>${waData.prodId}</td> |
| 23 | <td class='row'>${waData.isFixed}</td> |
| 24 | <td class='row'>${waData.waInfo}</td> |
| 25 | </tr>""" |
| 26 | reportContent = "${reportContent}${reportTemplate}" |
| 27 | } |
| 28 | } |
| 29 | stage('Generate report') { |
| 30 | sh "rm -rf ${reportDir}" |
| 31 | sh "mkdir -p ${reportDir}" |
| 32 | def reportHead = """<html> |
| 33 | <head> |
| 34 | <title>WA verify report</title> |
| 35 | </head> |
| 36 | <body> |
| 37 | <h1>WA verify report</h1> |
| 38 | <table border='1' cellpadding='5' cellspacing='0' style='border-collapse:collapse'> |
| 39 | <tr> |
| 40 | <th class='row'>Prod id</th> |
| 41 | <th class='row'>Status</th> |
Vladimir Khlyunev | fe415cc | 2022-08-02 13:58:43 +0400 | [diff] [blame] | 42 | <th class='row'>Comment</th> |
Roman Lubianyi | 1ee6256 | 2021-11-08 15:05:45 +0200 | [diff] [blame] | 43 | </tr>""" |
| 44 | def reportTail = """ |
| 45 | </table> |
| 46 | </body> |
| 47 | </html>""" |
| 48 | writeFile file: "${reportDir}report.html", text: "${reportHead}${reportContent}${reportTail}" |
| 49 | archiveArtifacts artifacts: "${reportDir}/*" |
| 50 | } |
| 51 | } catch (Throwable e) { |
| 52 | // If there was an error or exception thrown, the build failed |
| 53 | currentBuild.result = "FAILURE" |
| 54 | currentBuild.description = currentBuild.description ? e.message + " " + currentBuild.description : e.message |
| 55 | throw e |
| 56 | } |
| 57 | } |
| 58 | } |