-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
194 lines (142 loc) · 7.02 KB
/
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
def getSchemaFromGitea(branch, credentials,project_folder) {
sh "rm -r -f "+project_folder
withCredentials([string(credentialsId: credentials, variable: 'gitea_token')]) {
// some block
sh "git clone -c http.sslVerify=false -b " + "develop" + " https://" + gitea_token + ":[email protected]/gitea/platform/"+project_folder
sh "cd "+project_folder+" && git fetch --all"
try {
sh "cd "+project_folder+" && git checkout -b " + branch
}
catch(Exception e1) {
sh "cd "+project_folder+" && git checkout " + branch
println(e1);
//Catch block
}
try {
sh "cd "+project_folder+" && git pull origin " + branch
}
catch(Exception e1) {
println(e1);
//Catch block
}
//sh "cp -r "+project_folder+"/formSchema/UIconfig.js ./phenostore_server/config/."
}
}
def getConfigFromGitea(branch, credentials,project_folder) {
sh "rm -r -f "+project_folder
withCredentials([string(credentialsId: credentials, variable: 'gitea_token')]) {
// some block
sh "git clone -c http.sslVerify=false -b " + "develop" + " https://" + gitea_token + ":[email protected]/gitea/platform/" +project_folder
sh "cd "+project_folder+" && git fetch --all"
try {
sh "cd "+project_folder+" && git checkout -b " + branch
}
catch(Exception e1) {
sh "cd "+project_folder+" && git checkout " + branch
println(e1);
//Catch block
}
try {
sh "cd "+project_folder+" && git pull origin " + branch
}
catch(Exception e1) {
println(e1);
//Catch block
}
//sh "cp -r "+project_folder+"/config_test.py ./phenostore_server/config/."
sh "cp -r "+project_folder+"/config.py ./server"
}
}
def BuildAndCopyMibsHere(branch, credentials,project_folder,content) {
sh "rm -r -f "+project_folder
withCredentials([string(credentialsId: credentials, variable: 'gitea_token')]) {
// some block
sh "git clone -c http.sslVerify=false -b " + "develop" + " https://" + gitea_token + ":[email protected]/gitea/platform/"+project_folder+" "+project_folder
sh "cd "+project_folder+" && git fetch --all"
try {
sh "cd "+project_folder+" && git checkout -b " + branch
}
catch(Exception e1) {
sh "cd "+project_folder+" && git checkout " + branch
println(e1);
//Catch block
}
try {
sh "cd "+project_folder+" && git pull origin " + branch
}
catch(Exception e1) {
println(e1);
//Catch block
}
sh "cp "+content+" "+project_folder+"/."
sh "cd "+project_folder+" && if [ \$(git status --porcelain | wc -l) -gt 0 ]; then git add * && git commit -m 'Latest build' -i * && git push origin " + branch + "; else echo 'No chanegs to commit'; fi"
}
}
pipeline {
agent any
stages {
stage('install requirements') {
steps {
withPythonEnv('python3'){
sh 'pip install pip==22.1.1'
sh 'pip install -r requirements.txt'
}
}
}
stage('run test') {
steps {
withPythonEnv('python3'){
withCredentials([string(credentialsId: 'playground_password', variable: 'password')]) {
sh 'export username=test'
sh 'pytest'
//sh 'docker run --net=host --name postgres_test_genomed -e POSTGRES_PASSWORD=mysecretpassword -d postgres'
//sh "rm -rf federate_central_server_config"
//getConfigFromGitea(env.BRANCH_NAME,"gitea_config","federate_central_server_config")
//sh 'pytest --cov-report xml:phenostore_server/tests/coverage.xml --cov=. phenostore_server/tests/test_*'
//sh 'rm -r -f phenostore_server/attachments/rdconnect'
//sh 'docker rm -f '+'$(docker ps -aqf "name=postgres_test_flask")'
}
}
}
}
/* stage('Sonarqube') {
environment {
scannerHome = tool 'SQScanner'
SONAR_SCANNER_OPTS = '-Djavax.net.ssl.trustStore=/home/ujenkins/cacerts -Djavax.net.ssl.trustStorePassword=changeit -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044'
}
steps {
withSonarQubeEnv('SQServer') {
withCredentials([string(credentialsId: 'sonar_token', variable: 'sonar_token')]) {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=phenostore_server -Dsonar.login=${sonar_token}"
}
}
}
}
stage("Quality Gate") {
environment {
scannerHome = tool 'SQScanner'
SONAR_SCANNER_OPTS = '-Djavax.net.ssl.trustStore=/home/ujenkins/cacerts -Djavax.net.ssl.trustStorePassword=changeit -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1044'
}
steps {
timeout(time: 15, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
script{
def qg = waitForQualityGate()
if(qg.status != 'OK'){
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
} */
}
post {
success {
slackSend color: "good", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was successful"
}
failure {
//sh 'docker rm -f '+'$(docker ps -aqf "name=postgres_test_genomed")'
slackSend color: "danger", message: "Job: ${env.JOB_NAME} with buildnumber ${env.BUILD_NUMBER} was failed"
}
}
}