-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile-snyk
56 lines (55 loc) · 1.6 KB
/
Jenkinsfile-snyk
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
pipeline {
agent any
environment {
PATH = "$PATH:/usr/local/bin/"
IMAGETAG = ""
}
tools {
maven 'maven@latest'
snyk 'snyk@latest'
}
triggers {
GenericTrigger (
causeString: 'Triggered on push', genericVariables: [[defaultValue: '', key: 'branch', regexpFilter: '', value: '$.push.changes[0].old.name']], printContributedVariables: true, printPostContent: true, regexpFilterExpression: '^(master)*?$', regexpFilterText: '$branch', token: 'demo', tokenCredentialId: ''
)
}
stages {
stage('Git Clone') {
steps {
// cleanWs()
git branch: 'master', credentialsId: 'github-login', url: 'https://github.com/watri/demo.git'
}
}
stage('Change Jar Version') {
steps {
sh '''
#!/bin/bash
sed -i "s|dcid|${BUILD_NUMBER}|g" pom.xml
sed -i "s|dcid|${BUILD_NUMBER}|g" Dockerfile
chmod +x mvnw
whoami
'''
}
}
stage('Build') {
steps {
sh 'mvn clean install -Dmaven.test.skip=true'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('SAST Using Snyk') {
steps {
echo 'Testing...'
snykSecurity(
snykInstallation: 'snyk@latest',
snykTokenId: 'synk-api',
severity: 'critical',
)
}
}
}
}