Blame view
kea_testing.groovy
3.16 KB
a7a0d7905 Add initial Jenki... |
1 2 3 4 5 6 7 8 9 10 |
/** * Jenkinsfile to deploy multiple Docker containers based on docker-compose into a DEV server and run any test. * This pipeline will run the Docker containers, execute the tests and then stop and remove the containers from the DEV * server automatically. **/ pipeline { agent any |
097a24e19 Fix whitespace |
11 |
environment { |
a7a0d7905 Add initial Jenki... |
12 13 14 15 16 17 |
// Keep as is the following two lines PRIVATE_REGISTRY = "https://registry.curex-project.eu:443/curex-local/" ARTIFACTORY_URL = "registry.curex-project.eu:443/curex-local/" DEPLOYMENT_HOST = "116.203.166.220:2376" DEPLOYMENT_HOST_CREDENTIALS = "vm2-creds" |
fb793d4ad Revert "Revert "A... |
18 19 |
// KEA specific |
35edb5121 Quote variables |
20 21 22 |
APP_NAME = "KEA" APP_ENV = "production" APP_DEBUG = "true" |
86ce1f07a Use localhost for... |
23 |
APP_URL = "http://localhost" |
fb793d4ad Revert "Revert "A... |
24 |
|
35edb5121 Quote variables |
25 |
LOG_CHANNEL = "stack" |
fb793d4ad Revert "Revert "A... |
26 |
|
35edb5121 Quote variables |
27 28 29 30 31 32 |
DB_CONNECTION = "pgsql" DB_HOST = "timescaledb" DB_PORT = "5432" DB_DATABASE = "kea" DB_USERNAME = "postgres" DB_PASSWORD = "postgres" |
fb793d4ad Revert "Revert "A... |
33 |
|
35edb5121 Quote variables |
34 35 36 37 38 |
BROADCAST_DRIVER = "log" CACHE_DRIVER = "file" QUEUE_CONNECTION = "sync" SESSION_DRIVER = "file" SESSION_LIFETIME = "120" |
fb793d4ad Revert "Revert "A... |
39 |
|
35edb5121 Quote variables |
40 |
JWT_TTL = "1440" |
fb793d4ad Revert "Revert "A... |
41 |
|
35edb5121 Quote variables |
42 43 44 |
ELASTICSEARCH_HOST = "elasticsearch" ELASTICSEARCH_PORT = "9200" ELASTICSEARCH_SCHEME = "http" |
fb793d4ad Revert "Revert "A... |
45 |
|
35edb5121 Quote variables |
46 47 48 49 50 |
MQTT_HOST = "mosquitto" MQTT_PORT = "1883" MQTT_DEBUG = "false" MQTT_QOS = "0" MQTT_RETAIN = "0" |
fb793d4ad Revert "Revert "A... |
51 |
|
35edb5121 Quote variables |
52 53 54 55 |
MLTD_HOST = "mltd" MLTD_PORT = "5000" OD_HOST = "od" OD_PORT = "9091" |
a7a0d7905 Add initial Jenki... |
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
} stages { stage('Checkout the source code') { steps { checkout scm } } stage('Deploy Docker containers in DEV server') { steps { script { docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") { docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') { |
a7a0d7905 Add initial Jenki... |
72 73 |
echo 'Deploying the specified Docker containers in DEV server' sh 'sh deploy.sh' |
a7a0d7905 Add initial Jenki... |
74 75 76 77 78 |
} } } } } |
097a24e19 Fix whitespace |
79 80 |
stage('Run tests') { |
a7a0d7905 Add initial Jenki... |
81 82 |
steps { script { |
f7afd8ea9 Add a simple test |
83 84 85 |
echo '*************' echo '*** TESTS ***' echo '*************' |
a7a0d7905 Add initial Jenki... |
86 |
/* Here do your tests */ |
f7afd8ea9 Add a simple test |
87 88 89 |
sleep 50 try { String testName = "1. Check that app is running - 200 response code" |
86ce1f07a Use localhost for... |
90 |
String url = "$APP_URL" |
f7afd8ea9 Add a simple test |
91 92 93 94 95 96 97 98 |
String responseCode = sh(label: testName, script: "curl -m 10 -sLI -w '%{http_code}' $url -o /dev/null", returnStdout: true) if (responseCode != '200') { error("$testName: Returned status code = $responseCode when calling $url") } } catch (ignored) { currentBuild.result = 'FAILURE' echo "KEA Deployment Tests failed" } |
a7a0d7905 Add initial Jenki... |
99 100 101 |
} } } |
097a24e19 Fix whitespace |
102 |
stage('Stop and remove the Docker containers in DEV server') { |
a7a0d7905 Add initial Jenki... |
103 104 105 106 107 108 109 110 111 112 113 114 115 |
steps { script { docker.withServer("$DEPLOYMENT_HOST", "$DEPLOYMENT_HOST_CREDENTIALS") { docker.withRegistry("$PRIVATE_REGISTRY" , 'artifactory') { echo 'Stop and remove the specified Docker containers from the DEV server' sh 'sh delete.sh' } } } } } |
a7a0d7905 Add initial Jenki... |
116 117 |
} } |
097a24e19 Fix whitespace |
118 |