forked from konveyor/tackle-ui-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PR_TESTER.jenkinsfile
106 lines (104 loc) · 3.59 KB
/
PR_TESTER.jenkinsfile
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
@Library('migrationqe-automation-lib') _
def getChangedFilesList() {
ArrayList<String> changedFiles = new ArrayList<String>()
changedFiles = sh(script:"git diff \$(git merge-base origin/main HEAD) HEAD --name-only",
returnStdout:true).split('\n')
return changedFiles
}
pipeline{
agent {
label 'minikube-node'
}
options{
ansiColor('xterm')
}
environment{
REQUESTS_CA_BUNDLE="/etc/pki/tls/certs/ca-bundle.crt"
username="admin"
password="Dog8code"
TACKLE_GIT_CREDS = credentials('tackle_git_pass')
TACKLE_GIT_KEY = credentials('tackle_git_gpg_key')
cypress_jira_atlassian_cloud_url="https://mta-qe-testing.atlassian.net/"
cypress_jira_atlassian_cloud_email="mta.qe.testing@gmail.com"
cypress_jira_stage_datacenter_url="https://issues.stage.redhat.com"
cypress_jira_stage_bearer_token= credentials('mta_jira_stage_token')
cypress_jira_atlassian_cloud_token= credentials('mta_jira_cloud_token')
cypress_jira_stage_basic_login="mta-qe"
cypress_jira_stage_basic_password="Mta.qe.testing"
cypress_jira_atlassian_cloud_project="mta_integration"
}
stages{
stage("Check if their are changed tests"){
when{
allOf{
branch pattern: '^PR-.*$',
comparator: 'REGEXP';
expression{
getChangedFilesList().any { it=~ /^.*e2e\/tests\/.*test.ts$/} == true
}
}
}
steps{
script{
checkout scm
env.RUN_TESTS = "true"
changed_test_list = []
getChangedFilesList().each{
i ->
if(i.contains("test.ts")){
changed_test_list.add(i)
}
}
env.CHANGED_TEST_FILES = changed_test_list.join(" ")
sh "echo $CHANGED_TEST_FILES"
}
}
}
stage('Install & run minikube'){
when {
expression{
env.RUN_TESTS == "true"
}
}
steps{
script{
tackle.deployKonveyorOnMinikube()
echo "Applying tackle CR"
tackle.applyTackleCR()
}
}
}
stage('Run tackle ui tests'){
when {
expression{
env.RUN_TESTS == "true"
}
}
steps{
script{
env.TACKLE_URL = "http://"+sh(
script : 'minikube ip',
returnStdout: true
).trim()
ocp.pollRouteUntilReady(env.TACKLE_URL,15,30)
sh "sleep 40s" //Grace period after the application is serving correctly.
sh(
script: "npm install",
label: "Install dependencies..."
)
//Run the tests.
sh """
npx cypress run --spec $CHANGED_TEST_FILES --env user=$username,pass=$password,tackleUrl=$TACKLE_URL,git_user=$TACKLE_GIT_CREDS_USR,git_password=$TACKLE_GIT_CREDS_PSW,git_key='$TACKLE_GIT_KEY'
"""
}
}
}
}
post{
always{
script{
cleanWs()
}
}
}
}