-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
146 lines (137 loc) · 5.67 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
//
// Copyright (c) 2017 Dell Inc. or its subsidiaries. All Rights Reserved.
// Dell EMC Confidential/Proprietary Information
//
//
pipeline {
agent {
docker {
image 'rackhd/golang:1.8.0'
label 'maven-builder'
customWorkspace "workspace/${env.JOB_NAME}"
}
}
environment {
GIT_CREDS = credentials('github-03')
GITHUB_TOKEN = credentials('github-02')
}
options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '30', artifactNumToKeepStr: '5', daysToKeepStr: '30', numToKeepStr: '5'))
timestamps()
}
stages {
stage('Dependencies') {
steps {
sh '''
export GIT_SSL_NO_VERIFY=1
mkdir -p /go/src/github.com/dellemc-symphony/workflow-cli
cp -r . /go/src/github.com/dellemc-symphony/workflow-cli/
cd /go/src/github.com/dellemc-symphony/workflow-cli/
make creds
make deps
'''
}
}
stage('Unit Tests') {
steps {
sh '''
cd /go/src/github.com/dellemc-symphony/workflow-cli/
make unit-test
'''
}
}
stage('Integration Tests') {
steps {
sh '''
cd /go/src/github.com/dellemc-symphony/workflow-cli/
make integration-test
'''
}
}
stage('NexB Scan') {
when {
branch 'master'
}
steps {
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'nexB']],
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/nexB/scancode-toolkit.git']]])
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'workflow-cli']],
gitTool: 'linux-git',
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: 'github-03', url: 'https://github.com/dellemc-symphony/workflow-cli.git']]])
sh "mkdir -p nexB/nexb-output/"
sh "nexB/scancode --help"
sh "nexB/scancode --format html ${WORKSPACE}/workflow-cli nexB/nexb-output/workflow-cli.html"
sh "nexB/scancode --format html-app ${WORKSPACE}/workflow-cli nexB/nexb-output/workflow-cli-grap.html"
// sh "mv nexB/nexb-output/ ${WORKSPACE}/"
archiveArtifacts '**/nexb-output/**'
}
}
stage('Release') {
when {
branch 'master'
}
steps {
sh '''
export BUILD_ID=$(git describe --always --dirty)
go get -u github.com/aktau/github-release
cd /go/src/github.com/dellemc-symphony/workflow-cli/
make build
tar -czvf release-v0.0.1-${BUILD_ID}-windows.tgz bin/windows
tar -czvf release-v0.0.1-${BUILD_ID}-mac.tgz bin/darwin
tar -czvf release-v0.0.1-${BUILD_ID}-linux.tgz bin/linux
github-release release \
--user dellemc-symphony \
--repo workflow-cli \
--tag v0.0.1-${BUILD_ID} \
--name "Workflow CLI Release" \
--description "Workflow CLI Release"
github-release upload \
--user dellemc-symphony \
--repo workflow-cli \
--tag v0.0.1-${BUILD_ID} \
--name "WorkflowCLI-Windows.tgz" \
--file release-v0.0.1-${BUILD_ID}-windows.tgz
github-release upload \
--user dellemc-symphony \
--repo workflow-cli \
--tag v0.0.1-${BUILD_ID} \
--name "WorkflowCLI-Mac.tgz" \
--file release-v0.0.1-${BUILD_ID}-mac.tgz
github-release upload \
--user dellemc-symphony \
--repo workflow-cli \
--tag v0.0.1-${BUILD_ID} \
--name "WorkflowCLI-Linux.tgz" \
--file release-v0.0.1-${BUILD_ID}-linux.tgz
'''
}
}
}
post {
always{
step([$class: 'WsCleanup'])
}
success {
emailext attachLog: true,
body: 'Pipeline job ${JOB_NAME} success. Build URL: ${BUILD_URL}',
recipientProviders: [[$class: 'CulpritsRecipientProvider']],
subject: 'SUCCESS: Jenkins Job- ${JOB_NAME} Build No- ${BUILD_NUMBER}',
to: 'pebuildrelease@vce.com'
}
failure {
emailext attachLog: true,
body: 'Pipeline job ${JOB_NAME} failed. Build URL: ${BUILD_URL}',
recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'], [$class: 'FailingTestSuspectsRecipientProvider'], [$class: 'UpstreamComitterRecipientProvider']],
subject: 'FAILED: Jenkins Job- ${JOB_NAME} Build No- ${BUILD_NUMBER}',
to: 'pebuildrelease@vce.com'
}
}
}