forked from CMYanko/struts2-rce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
74 lines (56 loc) · 2.33 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
import groovy.json.*
node () {
def mvnHome, commitId
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
// git '[email protected]:CMYanko/struts2-showcase-demo.git'
checkout scm
// Get the Maven tool.
// ** NOTE: This 'M3' Maven tool must be configured
// ** in the global configuration.
// mvnHome = tool 'M3'
// sh 'git rev-parse HEAD > commit'
// commitId = readFile('commit').trim()
// sh "echo my commitid ${commitId}"
}
stage('Build') {
// Run the maven build
try{
if (isUnix()) {
sh "./mvnw -B -Dmaven.test.failure.ignore clean package"
} else {
bat("mvnw.cmd -B -Dmaven.test.failure.ignore clean package")
}
currentBuild.result = 'SUCCESS'
}catch(Exception err){
currentBuild.result = 'FAILURE'
}
sh "echo current build status ${currentBuild.result}"
/*
if (currentBuild.result == 'FAILURE') {
postGitHub(commitId, 'failure', 'build', 'Build failed')
return
} else {
postGitHub(commitId, 'success', 'build', 'Build succeeded')
} */
}
stage('Lifecycle Evaluation'){
// postGitHub commitId, 'pending', 'analysis', 'Nexus Lifecycle Analysis is running'
def policyEvaluationResult = nexusPolicyEvaluation failBuildOnNetworkError: false, iqApplication: '1422', iqStage: 'stage-release', jobCredentialsId: ''
/* if (currentBuild.result == 'FAILURE'){
postGitHub commitId, 'failure', 'analysis', 'Nexus Lifecycle Analysis failed',"${policyEvaluationResult.applicationCompositionReportUrl}"
return
} else {
postGitHub commitId, 'success', 'analysis', 'Nexus Lifecycle Analysis succeeded',"${policyEvaluationResult.applicationCompositionReportUrl}"
} */
}
}
def postGitHub(commitId, state, context, description, target_url="http://localhost:8080") {
def payload = JsonOutput.toJson(
state: state,
context: context,
description: description,
target_url: target_url
)
sh "curl -H \"Authorization: token ${gitHubApiToken}\" --request POST --data '${payload}' https://api.github.com/repos/${project}/statuses/${commitId}"
}