forked from openshift/assisted-test-infra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.test
77 lines (66 loc) · 2.62 KB
/
Jenkinsfile.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
pipeline {
agent { label 'test-infra' }
parameters {
booleanParam(name: 'NOTIFY', defaultValue: true, description: 'Notify on fail (on master branch)')
}
environment {
SKIPPER_PARAMS = " "
PROFILE = "minikube"
NAMESPACE = "assisted-installer"
E2E_TESTS_MODE="true"
/* Credentials */
PULL_SECRET = credentials('assisted-test-infra-pull-secret')
OCPMETAL_CREDS = credentials('docker_ocpmetal_cred')
BASE_DNS_DOMAINS = credentials('route53_dns_domain')
ROUTE53_SECRET = credentials('route53_secret')
SLACK_TOKEN = credentials('slack-token')
}
options {
timeout(time: 5, unit: 'HOURS')
}
stages {
stage('Init') {
steps {
sh "make image_build"
sh "make create_full_environment"
// Login
sh "minikube --profile ${PROFILE} ssh \"docker login --username ${OCPMETAL_CREDS_USR} --password ${OCPMETAL_CREDS_PSW}\""
}
}
stage('Test') {
steps {
sh "make run"
sh "make test"
}
post {
always {
junit '**/reports/*test.xml'
}
}
}
}
post {
always {
script {
if ((env.BRANCH_NAME == 'master') && env.NOTIFY && (currentBuild.currentResult == "ABORTED" || currentBuild.currentResult == "FAILURE")){
script {
def data = [text: "Attention! ${BUILD_TAG} job failed, see: ${BUILD_URL}"]
writeJSON(file: 'data.txt', json: data, pretty: 4)
}
sh '''curl -X POST -H 'Content-type: application/json' --data-binary "@data.txt" https://hooks.slack.com/services/${SLACK_TOKEN}'''
}
try {
ip = sh(returnStdout: true, script: "minikube ip --profile ${PROFILE}").trim()
minikube_url = "https://${ip}:8443"
sh "kubectl --server=${minikube_url} get pods -A"
for (service in ["assisted-service","postgres","scality","createimage"]) {
sh "kubectl --server=${minikube_url} get pods -o=custom-columns=NAME:.metadata.name -A | grep ${service} | xargs -r -I {} sh -c \"kubectl --server=${minikube_url} logs {} -n ${NAMESPACE} > {}.log\" || true"
}
} finally {
sh "make destroy"
}
}
archiveArtifacts artifacts: '*.log', fingerprint: true
}
}
}