[DO-1142] add test and notification (!37)
Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/37 Reviewed-by: Aleksandr Vodyanov <aleksandr.vodyanov@avroid.tech>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
@Library('shared-lib') _
|
||||
|
||||
import tech.avroid.jenkins.Notifications
|
||||
import groovy.json.JsonOutput
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
properties([
|
||||
@@ -12,6 +14,66 @@ properties([
|
||||
|
||||
])
|
||||
|
||||
List tests = [
|
||||
[ expectedCode: '201',
|
||||
method: 'POST',
|
||||
URL: '/api/activate',
|
||||
body: [
|
||||
"activation_key_id": "C0AE-AC61-20E0-18D5",
|
||||
"vendor_app_id": "tavro_aurora",
|
||||
"device_id": "FCA4PZgXnFBJUfQUpXlS3iyqXcXog9Qd8xEa8qp267I=",
|
||||
"app_version": "5.2.4",
|
||||
"check_only": false
|
||||
]
|
||||
],
|
||||
[ expectedCode: '404',
|
||||
method: 'POST',
|
||||
URL: '/api/activate',
|
||||
body: [
|
||||
"activation_key_id": "C0AE-AC61-20E0-18D",
|
||||
"vendor_app_id": "tavro_aurora",
|
||||
"device_id": "FCA4PZgXnFBJUfQUpXlS3iyqXcXog9Qd8xEa8qp267I=",
|
||||
"app_version": "5.2.4",
|
||||
"check_only": false
|
||||
]
|
||||
],
|
||||
[ expectedCode: '201',
|
||||
method: 'POST',
|
||||
URL: '/api/activate',
|
||||
body: [
|
||||
"activation_key_id": "C0AE-AC61-20E0-18D5",
|
||||
"vendor_app_id": "tavro_aurora",
|
||||
"device_id": "FCA4PZgXnFBJUfQUpXlS3iyqXcXog9Qd8xEa8qp267I=",
|
||||
"app_version": "5.0.1",
|
||||
"check_only": false
|
||||
]
|
||||
],
|
||||
[ expectedCode: '400',
|
||||
method: 'POST',
|
||||
URL: '/api/activate',
|
||||
body: [
|
||||
"activation_key_id": "C0AE-AC61-20E0-18D5",
|
||||
"vendor_app_id": "tavro_aurora",
|
||||
"device_id": "FCA4PZgXnFBJUfQUpXlS3iyqXcXog9Qd8xEa8qp267I=",
|
||||
"app_version": "1.2.4",
|
||||
"check_only": false
|
||||
]
|
||||
],
|
||||
[ expectedCode: '201',
|
||||
method: 'POST',
|
||||
URL: '/api/activate',
|
||||
body: [
|
||||
"activation_key_id": "A7F9-072A-D239-7D67",
|
||||
"vendor_app_id": "tavro_aurora_lite",
|
||||
"device_id": "[AvroidActivation]",
|
||||
"app_version": "5.2.4",
|
||||
"check_only": true
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
String recipient = "devops@avroid.team"
|
||||
|
||||
Object date = new Date()
|
||||
Object todayDate = new SimpleDateFormat("yyyy-MM-dd")
|
||||
|
||||
@@ -44,6 +106,7 @@ String cmdRestoreDB = "docker exec postgresql pg_restore -Fc -U postgres -p 5432
|
||||
String cmdClearTmp = "rm -rf /home/jenkins/*"
|
||||
|
||||
node('slave01') {
|
||||
try {
|
||||
stage('Restore backup') {
|
||||
withVault([configuration: configuration, vaultSecrets: sshPassword]) {
|
||||
sh """
|
||||
@@ -58,4 +121,34 @@ node('slave01') {
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Run tests'){
|
||||
tests.each { test ->
|
||||
httpRequest(
|
||||
url: "http://${licBackupServer}${test.URL}",
|
||||
contentType: 'APPLICATION_JSON',
|
||||
httpMode: test.method,
|
||||
validResponseCodes: test.expectedCode,
|
||||
requestBody: JsonOutput.toJson(test.body)
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch(err) {
|
||||
errorMessage = err.getMessage()
|
||||
|
||||
println 'ERROR: ' + errorMessage
|
||||
|
||||
currentBuild.result = 'FAILURE'
|
||||
|
||||
String emailSubject = "${currentBuild.currentResult}. " +
|
||||
"Pipeline task: ${currentBuild.fullDisplayName}"
|
||||
Notifications.email(
|
||||
script: this,
|
||||
subject: emailSubject,
|
||||
errorString: errorMessage,
|
||||
recipientProviders: [],
|
||||
to: recipient
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user