Skip to content

Commit 80dbc00

Browse files
Optimize jenkins build
1 parent e973a39 commit 80dbc00

File tree

1 file changed

+36
-105
lines changed

1 file changed

+36
-105
lines changed

Jenkinsfile

+36-105
Original file line numberDiff line numberDiff line change
@@ -12,121 +12,52 @@ properties([
1212
])
1313

1414
def buildCacheImage = "git.auckland.dynabic.com:4567/words-cloud/api/cpp"
15-
def needToBuildWindows = false
16-
def needToBuildLinux = false
17-
def packageTestingWindows = false
18-
def packageTestingLinux = false
15+
def needToBuild = false
16+
def packageTesting = false
1917

20-
parallel windows: {
21-
node('windows2019') {
22-
try {
23-
stage('windows_checkout'){
24-
packageTestingWindows = params.packageTesting
25-
if (packageTestingWindows) {
26-
needToBuildWindows = true
27-
checkout([$class: 'GitSCM', branches: [[name: 'release']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-cpp.git']]])
28-
}
29-
else {
30-
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-cpp.git']]])
31-
bat 'git show -s HEAD > gitMessage'
32-
def commitMessage = readFile('gitMessage').trim()
33-
echo commitMessage
34-
needToBuildWindows = params.ignoreCiSkip || !commitMessage.contains('[ci skip]')
35-
}
36-
37-
bat 'git clean -fdx'
18+
node('words-linux') {
19+
try {
20+
stage('checkout'){
21+
packageTesting = params.packageTesting
22+
if (packageTesting) {
23+
needToBuild = true
24+
checkout([$class: 'GitSCM', branches: [[name: 'release']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/aspose-words-cloud/aspose-words-cloud-cpp.git']]])
3825
}
39-
40-
if (needToBuildWindows) {
41-
stage('windows_build') {
42-
withCredentials([usernamePassword(credentialsId: 'cc2e3c9b-b3da-4455-b702-227bcce18895', usernameVariable: 'dockerrigistry_login', passwordVariable: 'dockerregistry_password')]) {
43-
bat 'docker login -u "%dockerrigistry_login%" -p "%dockerregistry_password%" git.auckland.dynabic.com:4567'
44-
bat """
45-
docker pull ${buildCacheImage}/wincore:latest
46-
docker build --cache-from=${buildCacheImage}/wincore:latest -t ${buildCacheImage}/wincore:latest -t aspose-words-cloud-cpp-tests:wincore - < Dockerfile.wincore || goto error
47-
docker build -t aspose-words-cloud-cpp-tests:windows -f Dockerfile.windows . || goto error
48-
docker push ${buildCacheImage}/wincore:latest || goto error
49-
exit /b 0
50-
51-
:error
52-
exit /b 255
53-
"""
54-
bat (script: "docker build -t aspose-words-cloud-cpp-tests:windows -f Dockerfile.windows .")
55-
}
56-
}
57-
stage('windows_tests') {
58-
withCredentials([usernamePassword(credentialsId: params.credentialsId, passwordVariable: 'WordsClientSecret', usernameVariable: 'WordsClientId')]) {
59-
try {
60-
bat (script: "docker build -t aspose-words-cloud-cpp-tests:windows -f Dockerfile.windows .")
61-
def apiUrl = params.apiUrl
62-
bat """
63-
if exist out rmdir out /s /q
64-
mkdir out
65-
66-
docker run --rm --env accept_eula=Y --memory 4G -v "%cd%/out:C:/out" aspose-words-cloud-cpp-tests:windows cmd /c ".\\scripts\\runTestsDocker.bat %WordsClientId% %WordsClientSecret% %apiUrl%"
67-
exit /b %ERRORLEVEL%
68-
"""
69-
archiveArtifacts artifacts: '**\\out\\windows-x64.zip'
70-
} finally {
71-
junit '**\\out\\test_result.xml'
72-
}
73-
74-
if (currentBuild.result == "UNSTABLE") {
75-
currentBuild.result = "FAILURE"
76-
}
77-
}
78-
}
26+
else {
27+
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-cpp.git']]])
28+
sh 'git show -s HEAD > gitMessage'
29+
def commitMessage = readFile('gitMessage').trim()
30+
echo commitMessage
31+
needToBuild = params.ignoreCiSkip || !commitMessage.contains('[ci skip]')
7932
}
80-
} finally {
81-
deleteDir()
33+
34+
sh 'git clean -fdx'
8235
}
83-
}
84-
}, linux: {
85-
node('words-linux') {
86-
try {
87-
stage('linux_checkout'){
88-
packageTestingLinux = params.packageTesting
89-
if (packageTestingLinux) {
90-
needToBuildLinux = true
91-
checkout([$class: 'GitSCM', branches: [[name: 'release']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://github.com/aspose-words-cloud/aspose-words-cloud-cpp.git']]])
36+
37+
if (needToBuild) {
38+
stage('build') {
39+
withCredentials([usernamePassword(credentialsId: 'cc2e3c9b-b3da-4455-b702-227bcce18895', usernameVariable: 'dockerrigistry_login', passwordVariable: 'dockerregistry_password')]) {
40+
sh 'docker login -u "${dockerrigistry_login}" -p "${dockerregistry_password}" git.auckland.dynabic.com:4567'
41+
sh (script: "docker pull ${buildCacheImage}/linux:latest")
42+
sh (script: "docker build --cache-from=${buildCacheImage}/linux:latest -t ${buildCacheImage}/linux:latest -t aspose-words-cloud-cpp-tests:linux - < Dockerfile.linux")
43+
sh (script: "docker push ${buildCacheImage}/linux:latest")
9244
}
93-
else {
94-
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-cpp.git']]])
95-
sh 'git show -s HEAD > gitMessage'
96-
def commitMessage = readFile('gitMessage').trim()
97-
echo commitMessage
98-
needToBuildLinux = params.ignoreCiSkip || !commitMessage.contains('[ci skip]')
99-
}
100-
101-
sh 'git clean -fdx'
10245
}
103-
104-
if (needToBuildLinux) {
105-
stage('linux_build') {
106-
withCredentials([usernamePassword(credentialsId: 'cc2e3c9b-b3da-4455-b702-227bcce18895', usernameVariable: 'dockerrigistry_login', passwordVariable: 'dockerregistry_password')]) {
107-
sh 'docker login -u "${dockerrigistry_login}" -p "${dockerregistry_password}" git.auckland.dynabic.com:4567'
108-
sh (script: "docker pull ${buildCacheImage}/linux:latest")
109-
sh (script: "docker build --cache-from=${buildCacheImage}/linux:latest -t ${buildCacheImage}/linux:latest -t aspose-words-cloud-cpp-tests:linux - < Dockerfile.linux")
110-
sh (script: "docker push ${buildCacheImage}/linux:latest")
46+
stage('tests') {
47+
withCredentials([usernamePassword(credentialsId: params.credentialsId, passwordVariable: 'WordsClientSecret', usernameVariable: 'WordsClientId')]) {
48+
try {
49+
sh 'docker run --rm -v "$PWD/out:/out/" -v "$PWD:/aspose-words-cloud-cpp" aspose-words-cloud-cpp-tests:linux bash /aspose-words-cloud-cpp/scripts/runTestsDocker.sh $WordsClientId $WordsClientSecret $apiUrl'
50+
} finally {
51+
junit '**\\out\\test_result.xml'
11152
}
112-
}
113-
stage('linux_tests') {
114-
withCredentials([usernamePassword(credentialsId: params.credentialsId, passwordVariable: 'WordsClientSecret', usernameVariable: 'WordsClientId')]) {
115-
try {
116-
sh 'docker run --rm -v "$PWD/out:/out/" -v "$PWD:/aspose-words-cloud-cpp" aspose-words-cloud-cpp-tests:linux bash /aspose-words-cloud-cpp/scripts/runTestsDocker.sh $WordsClientId $WordsClientSecret $apiUrl'
117-
archiveArtifacts artifacts: '**\\out\\linux-x64.zip'
118-
} finally {
119-
junit '**\\out\\test_result.xml'
120-
}
121-
122-
if (currentBuild.result == "UNSTABLE") {
123-
currentBuild.result = "FAILURE"
124-
}
53+
54+
if (currentBuild.result == "UNSTABLE") {
55+
currentBuild.result = "FAILURE"
12556
}
12657
}
12758
}
128-
} finally {
129-
deleteDir()
13059
}
60+
} finally {
61+
deleteDir()
13162
}
13263
}

0 commit comments

Comments
 (0)