-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
86 lines (79 loc) · 2.51 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
pipeline {
agent {
docker {
image 'maven:3.8.1-adoptopenjdk-11'
args '-v /root/.m2:/root/.m2'
}
}
environment {
branchName = 'master'
projectName = 'jenkins_linux/JavaVulnerableLab_for_AST_sca_resolver'
projectTags = 'jvl_ast_sca_resolver'
repoUrl = 'https://github.com/jvlstuff/JavaVulnerableLab_for_AST.git'
projectGroup = 'myg'
scanTimeout = 40
scaName = 'ScaResolver'
workspace = "${WORKSPACE}"
scaResolverPath = ''
}
stages {
stage('Greeting') {
steps {
echo "Job [${JOB_NAME}] - in the Workspace of [${WORKSPACE}]!"
script {
if(isUnix()) {
sh "ls -lahR ${WORKSPACE} "
sh "cd ${WORKSPACE} "
} else {
bat "cd ${WORKSPACE}"
}
}
}
}
stage('SAST Scan') {
steps {
staticScan(branchName: branchName, credentialsId: 'ast-cx_sales_jurgen_elite_canary-cred', projectName: projectName)
}
}
}
}
void scaResolverInstallation(String scaDir) {
fileName = scaName + '.tar.gz'
filePath = "${scaDir}/${fileName}"
scaResolverDir = "${scaDir}"
scaResolverPath = "${scaResolverDir}/${scaName}"
fileOperations([
steps.fileDeleteOperation(
includes: fileName,
excludes: ''
),
fileDownloadOperation(
url: 'https://sca-downloads.s3.amazonaws.com/cli/latest/ScaResolver-linux64.tar.gz',
userName: '',
password: '',
targetLocation: scaResolverDir,
targetFileName: fileName
),
fileUnTarOperation(
filePath : filePath,
targetLocation : scaResolverDir,
isGZIP : true
)
])
}
void staticScan(Map args) {
scaResolverInstallation(workspace)
dir('sub') {
checkmarxASTScanner additionalOptions: "--debug --async --project-tags ${projectTags} --project-groups ${projectGroup} --scan-timeout ${scanTimeout} --sca-resolver ${scaResolverPath} --sca-resolver-params \" --log-level Verbose --scan-containers true \" ",
checkmarxInstallation: 'ast-cli-automatical',
baseAuthUrl: 'https://deu.iam.checkmarx.net',
serverUrl: 'https://deu.ast.checkmarx.net',
branchName: args.branchName,
credentialsId: args.credentialsId,
projectName: args.projectName,
tenantName: 'cx_sales_jurgen_elite_canary',
useAuthenticationUrl: true,
useOwnAdditionalOptions: true,
useOwnServerCredentials: true
}
}