-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.jenkins
152 lines (152 loc) · 5.67 KB
/
.jenkins
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
150
151
152
node('master'){
def cmdBaseDir='spring-server'
def buildCmd='mvn -Dmaven.test.failure.ignore clean install cobertura:cobertura -Dcobertura.report.format=xml'
def SonarUrl='http://sonar.service.ob.local:9000'
def DockerImageRegistry='http://registry.service.ob.local:5001'
def DockerBuildUrl='docker-build.service.ob.local:2375'
def DockerfilePath='spring-server'
def DockerImage='registry.service.ob.local:5001/t/test1027-dxq/java1030:master-$BUILD_TIMESTAMP'
def codeLanguage='java'
def scm_svn_url='http://svnadmin.service.ob.local:8090/svn/java1030/trunk'
def scm_svn_credentialId='credential_default_svn'
def scm_svn_branch='master'
if (isUnix()) {
stage('更新代码'){
parallel'1_更新代码_svn_task_1509440659483': {
def credentialId="credential_default_svn"
def type="svn"
def branch="master"
def url="http://svnadmin.service.ob.local:8090/svn/java1030/trunk"
checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: credentialId, depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: url]], workspaceUpdater: [$class: 'UpdateUpdater']])
}
}
stage('代码编译'){
dir("$cmdBaseDir"){
parallel'1_代码编译_all_task_1509440659486': {
def workspace="$cmdBaseDir"
def cmd="$buildCmd"
sh cmd
}
}
}
stage('代码检查'){
dir("$cmdBaseDir"){
parallel'1_代码检查_sonar_task_1509440659489': {
def workspace="$cmdBaseDir"
def sonarURL="$SonarUrl"
def credentialId="credential_default_sonar"
def language="$codeLanguage"
sh "sonar-scanner -Dsonar.host.url=${sonarURL} -X -Dsonar.login=${credentialId} -Dsonar.projectName=${JOB_NAME} -Dsonar.projectVersion='1.0' -Dsonar.projectKey=${JOB_NAME} -Dsonar.sources=. -Dsonar.language=${language} "
}
}
}
stage('单元测试'){
parallel'1_单元测试_junit_report_task_1509440659492': {
def testResults="**/*surefire-reports/**/*.xml"
junit allowEmptyResults: true, healthScaleFactor: 0.0, testResults: testResults
}
parallel'2_单元测试_cobertura_report_task_1509440659495': {
def coberturaReportFile="**/*target/site/cobertura/coverage.xml"
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: coberturaReportFile, failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
}
stage('打包'){
dir("$DockerfilePath"){
parallel'1_打包_docker_task_1509440659498': {
def dockerServer="$DockerBuildUrl"
def resUrl="$DockerImageRegistry"
def workspace="$DockerfilePath"
def resCredentialsId="credential_default_docker"
def outPutImage="$DockerImage"
withDockerServer([uri: dockerServer]) {
withDockerRegistry([credentialsId: resCredentialsId, url: resUrl]) {
def image = docker.build(outPutImage)
image.push();
}
}
}
}
}
stage('归档'){
parallel'1_归档_all_task_1509440659501': {
def workspace=""
def excludes=""
def includes="**/target/*.jar"
archiveArtifacts allowEmptyArchive: true, artifacts: includes, excludes: excludes
}
}
stage('部署'){
}
stage('自动测试'){
}
} else {
stage('更新代码'){
parallel'1_更新代码_svn_task_1509440659483': {
def credentialId="credential_default_svn"
def type="svn"
def branch="master"
def url="http://svnadmin.service.ob.local:8090/svn/java1030/trunk"
checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: credentialId, depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: url]], workspaceUpdater: [$class: 'UpdateUpdater']])
}
}
stage('代码编译'){
dir("$cmdBaseDir"){
parallel'1_代码编译_all_task_1509440659486': {
def workspace="$cmdBaseDir"
def cmd="$buildCmd"
bat cmd
}
}
}
stage('代码检查'){
dir("$cmdBaseDir"){
parallel'1_代码检查_sonar_task_1509440659489': {
def workspace="$cmdBaseDir"
def sonarURL="$SonarUrl"
def credentialId="credential_default_sonar"
def language="$codeLanguage"
bat "sonar-scanner -Dsonar.host.url=${sonarURL} -X -Dsonar.login=${credentialId} -Dsonar.projectName=${JOB_NAME} -Dsonar.projectVersion='1.0' -Dsonar.projectKey=${JOB_NAME} -Dsonar.sources=. -Dsonar.language=${language} "
}
}
}
stage('单元测试'){
parallel'1_单元测试_junit_report_task_1509440659492': {
def testResults="**/*surefire-reports/**/*.xml"
junit allowEmptyResults: true, healthScaleFactor: 0.0, testResults: testResults
}
parallel'2_单元测试_cobertura_report_task_1509440659495': {
def coberturaReportFile="**/*target/site/cobertura/coverage.xml"
step([$class: 'CoberturaPublisher', autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile:coberturaReportFile, failNoReports: false, failUnhealthy: false, failUnstable: false, maxNumberOfBuilds: 0, onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false])
}
}
stage('打包'){
dir("$DockerfilePath"){
parallel'1_打包_docker_task_1509440659498': {
def dockerServer="$DockerBuildUrl"
def resUrl="$DockerImageRegistry"
def workspace="$DockerfilePath"
def resCredentialsId="credential_default_docker"
def outPutImage="$DockerImage"
withDockerServer([uri: dockerServer]) {
withDockerRegistry([credentialsId: resCredentialsId, url: resUrl]) {
def image = docker.build(outPutImage)
image.push();
}
}
}
}
}
stage('归档'){
parallel'1_归档_all_task_1509440659501': {
def workspace=""
def excludes=""
def includes="**/target/*.jar"
archiveArtifacts allowEmptyArchive: true, artifacts: includes, excludes: excludes
}
}
stage('部署'){
}
stage('自动测试'){
}
}
}