forked from chamap1/travis-ci-tutorial-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
149 lines (149 loc) · 6.26 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
properties([
pipelineTriggers([
upstream(threshold: hudson.model.Result.SUCCESS, upstreamProjects: 'gitorg-test-purna/travis-ci-tutorial-java/master')
])
])
pipeline {
agent {
node{
// label 'maven-builder'
label 'builder-06'
customWorkspace "workspace/${env.JOB_NAME}"
}
}
environment {
//GIT_CREDS = credentials('github-04')
GITHUB_TOKEN = credentials('github-04')
}
tools {
maven 'linux-maven-3.3.9'
jdk 'linux-jdk1.8.0_102'
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
timestamps()
// properties([[$class: 'BuildBlockerProperty', blockLevel: <object of type hudson.plugins.buildblocker.BuildBlockerProperty.BlockLevel>, blockingJobs: 'simple-build-for-pipeline-plugin', scanQueueFor: <object of type hudson.plugins.buildblocker.BuildBlockerProperty.QueueScanScope>, useBuildBlocker: true], [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], pipelineTriggers([])])
// [$class: 'BuildBlockerProperty', blockLevel: <object of type hudson.plugins.buildblocker.BuildBlockerProperty.BlockLevel>, blockingJobs: 'root-parent', scanQueueFor: <object of type hudson.plugins.buildblocker.BuildBlockerProperty.QueueScanScope>, useBuildBlocker: true]
}
stages {
// stage('Environment Setup') {
// steps{
// deleteDir()
// }
// }
stage('Compile') {
steps {
build job:'gitorg-test-purna/simple-build-for-pipeline-plugin/master', wait: false
sh "mvn compile"
}
}
stage('Deploy') {
steps {
sh "mvn clean install"
sh "echo This is not deploying to any remote repository. Just for testing purpose."
}
}
stage('Unit Tests') {
steps {
sh "mvn test"
}
}
stage('Integration Tests') {
steps {
sh "echo No Integration tests defined for this repo!"
}
}
stage('SonarQube Analysis') {
steps{
withSonarQubeEnv('SonarQube') {
sh '''
mvn sonar:sonar \
-Dsonar.host.url=$SONAR_HOST_URL \
-Dsonar.login=$SONAR_AUTH_TOKEN \
-Dsonar.java.coveragePlugin=jacoco \
-Dsonar.junit.reportsPath=target/surefire-reports \
-Dsonar.jacoco.reportPath=target/coverage-reports/jacoco-ut.exec \
-Dsonar.jacoco.itReportPath=target/coverage-reports/jacoco-it.exec \
-Dsonar.dependencyCheck.reportPath=${WORKSPACE}/report/dependency-check-report.xml
'''
}
}
}
stage('Third Party Audit'){
steps{
sh "echo skipping this"
// sh "mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:analyze-report license:add-third-party org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -DoutputType=dot -DoutputFile=${WORKSPACE}/report//dependency-tree.dot"
// archiveArtifacts 'target/generated-sources/license/*,report/*'
}
}
stage('NexB Scan'){
steps{
dir('/opt') {
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'nexB-scancode']],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/nexB/scancode-toolkit.git']]])
}
dir('nexb-output'){
sh "sh /opt/nexB-scancode/scancode --help"
// sh "sh /opt/nexB-scancode/scancode --format html-app ${WORKSPACE} scancode_result.html"
// sh "sh /opt/nexB-scancode/scancode --format html ${WORKSPACE} minimal.html"
}
// archiveArtifacts '**/nexb-output/**'
}
}
stage('Copy Artifacts'){
steps{
step([$class: 'CopyArtifact', projectName: 'nexb-scan-test', filter: 'output/concerto/*'])
}
}
stage('Github Release'){
when{
expression{
return env.BRANCH_NAME ==~ /master|sample_branch|release\/.*/
}
}
steps{
dir('/opt') {
sh "rm -f linux-amd64-github-release.tar.bz2"
sh "wget https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2"
sh "tar -xvjf linux-amd64-github-release.tar.bz2"
sh "yes | cp bin/linux/amd64/github-release /usr/bin/"
// sh '''
// github-release release \
// --user chamap1 \
// --repo travis-ci-tutorial-java \
// --tag v0.0.1-${BRANCH_NAME}-${BUILD_ID} \
// --name "travis-ci-tutorial-java" \
// --description "travis-ci-tutorial-java release"
// github-release upload \
// --user chamap1 \
// --repo travis-ci-tutorial-java \
// --tag v0.0.1-${BRANCH_NAME}-${BUILD_ID} \
// --name "travis-ci-tutorial-java" \
// --file ${WORKSPACE}/target/travis-ci-tutorial.jar
// '''
}
}
}
}
post{
always{
step([$class: 'WsCleanup'])
}
success{
//steps to be performed
sh "echo Do Nothing"
}
failure{
//steps to be performed
sh "echo Do Nothing"
}
unstable{
//steps to be performed
sh "echo Do Nothing"
}
}
}