-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
78 lines (63 loc) · 2.06 KB
/
Jenkinsfile
File metadata and controls
78 lines (63 loc) · 2.06 KB
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
def runCommand = { strList ->
assert ( strList instanceof String ||
( strList instanceof List && strList.each{ it instanceof String } ) \
)
def proc = strList.execute()
proc.in.eachLine { line -> println line }
proc.out.close()
proc.waitFor()
print "[INFO] ( "
if(strList instanceof List) {
strList.each { print "${it} " }
} else {
print strList
}
println " )"
if (proc.exitValue()) {
println "gave the following error: "
println "[ERROR] ${proc.getErrorStream()}"
}
assert !proc.exitValue()
}
def showChangeLogs() {
def changedFiles = [];
def fileChange = false
def changeLogSets = currentBuild.changeSets
for (int i = 0; i < changeLogSets.size(); i++) {
def entries = changeLogSets[i].items
for (int j = 0; j < entries.length; j++) {
def entry = entries[j]
echo "${entry.commitId} by ${entry.author} on ${new Date(entry.timestamp)}: ${entry.msg}"
def files = new ArrayList(entry.affectedFiles)
for (int k = 0; k < files.size(); k++) {
def file = files[k]
echo " ${file.editType.name} ..File Path - ${file.path}"
if (file.path.endsWith(".java"))
{
fileChange = true
}
changedFiles += file.path
}
}
}
return changedFiles
}
node {
stage('Checkout') {
checkout scm
}
stage('Build') {
myFiles = showChangeLogs()
println "myFiles ${myFiles}"
def workspace = pwd()
def file1 = new File("${workspace}\\files.txt")
def covint = workspace+"\\covint"
def fileList = file1.getCanonicalPath()
println "Using File List {fileList}"
file1 << myFiles
buildCommand = ["C:\\Coverity\\cov-analysis-win64-2018.06\\bin\\cov-build", "--dir", covint, "--fs-capture-list", fileList, "--no-command"]
runCommand(buildCommand)
analysisCommand = ["C:\\Coverity\\cov-analysis-win64-2018.06\\bin\\cov-run-desktop", "--dir", covint, "--host", "localhost", "--user", "admin", "--password", "SIGpass8!", "--stream", "Empty", fileList]
runCommand(analysisCommand)
}
}