-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile
53 lines (48 loc) · 1.72 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
@Library('alvarium-pipelines') _
pipeline {
agent any
tools {
maven 'M3'
}
stages {
stage('prep - generate source code checksum') {
steps {
// Create a dir on the Jenkins worker to hold the checksum file
sh 'mkdir -p $JENKINS_HOME/jobs/$JOB_NAME/$BUILD_NUMBER/'
// $PWD is the workspace dir (the cloned repo), this will generate
// an md5sum (checksum) for the repo and write it to `sc_checksum` in
// the dir created above
sh ''' find . -type f -exec sha256sum {} + | LC_ALL=C sort | sha256sum |\
cut -d" " -f1 \
> $JENKINS_HOME/jobs/$JOB_NAME/$BUILD_NUMBER/sc_checksum
'''
}
}
// The source code annotator will give `isSatisfied=false` if the unit tests
// run before it, as they generate files in the workspace directory which will
// alter the source code checksum being generated
stage('alvarium - pre-build annotations') {
steps {
script{
def optionalParams = ['sourceCodeChecksumPath':"${JENKINS_HOME}/jobs/${JOB_NAME}/${BUILD_NUMBER}/sc_checksum"]
alvariumCreate(['source-code', 'vulnerability'], optionalParams)
}
}
}
stage('test') {
steps {
sh 'mvn test'
}
}
stage('build') {
steps {
sh 'mvn package'
}
post {
success {
archiveArtifacts artifacts: 'target/**/*.jar', fingerprint: true
}
}
}
}
}