@@ -6,7 +6,6 @@ def bash(command, returnOutput=false)
66 returnStdout : returnOutput)
77}
88
9-
109def SetGithubStatus (githubToken , context , targetUrl , desc , status , repoOwner , repoName , gitHash )
1110{
1211 bash """
@@ -25,7 +24,6 @@ def SetGithubStatus(githubToken, context, targetUrl, desc, status, repoOwner, re
2524 """
2625}
2726
28- def SKIP_PIPELINE = false
2927def REPO_OWNER = " Neko-Box-Coder"
3028def REPO_NAME = " runcpp2"
3129def TARGET_URL = ' https://github.com/Neko-Box-Coder/runcpp2.git'
@@ -37,32 +35,27 @@ def STORE_BUILD = false
3735pipeline
3836{
3937 agent none
40-
41- options
42- {
43- skipDefaultCheckout()
44- }
45-
38+ options { skipDefaultCheckout() }
4639/*
4740 External Variables for webhook payload:
4841
4942 Webhook:
5043 GITHUB_PUSH_REF: $.ref
51-
5244 GITHUB_PR_ACTION: $.action
5345 GITHUB_PR_GIT_URL: $.pull_request.head.repo.clone_url
5446 GITHUB_PR_REF: $.pull_request.head.ref
55-
5647 GITHUB_PR_REPO_OWNER: $.pull_request.user.login
5748 GITHUB_PR_REPO_NAME: $.pull_request.head.repo.name
58-
5949 X-GitHub-Event: (Header)
6050
51+ Trigger:
52+ $GITHUB_PUSH_REF , $GITHUB_PR_REF , $GITHUB_PR_ACTION
53+ ^refs/heads/master , , $|^ , .[a-zA-Z/]* , (opened|synchronize)$
54+
6155 Param:
6256 TARGET_REF
6357 STORE_BUILD
6458*/
65-
6659 stages
6760 {
6861 stage(' Setup' )
@@ -76,14 +69,10 @@ pipeline
7669 echo " env.STORE_BUILD: ${ env.STORE_BUILD} "
7770
7871 if (env. TARGET_REF != null )
79- {
8072 TARGET_REF = env. TARGET_REF
81- }
8273
8374 if (env. STORE_BUILD != null )
84- {
8575 STORE_BUILD = env. STORE_BUILD . toBoolean()
86- }
8776
8877 echo " Displaying Webhook Variables:"
8978 echo " GITHUB_PUSH_REF: ${ env.GITHUB_PUSH_REF} "
@@ -92,29 +81,19 @@ pipeline
9281 echo " GITHUB_PR_REF: ${ env.GITHUB_PR_REF} "
9382 echo " GITHUB_PR_REPO_OWNER: ${ env.GITHUB_PR_REPO_OWNER} "
9483 echo " GITHUB_PR_REPO_NAME: ${ env.GITHUB_PR_REPO_NAME} "
95-
9684 echo " X_GitHub_Event: ${ env.X_GitHub_Event} "
9785
9886 // Trigger pipeline on push to master
9987 if (env.X_GitHub_Event == ' push' )
10088 {
10189 if (env. GITHUB_PUSH_REF != ' refs/heads/master' )
102- {
103- echo " Setting SKIP_PIPELINE for push to true"
10490 error(' Receiving non master push' )
105- SKIP_PIPELINE = true
106- echo " SKIP_PIPELINE: ${ SKIP_PIPELINE} "
107- }
10891 }
10992 // Trigger pipeline with approval on PR
11093 else if (env.X_GitHub_Event == ' pull_request' )
11194 {
112- if ( env. GITHUB_PR_ACTION != ' synchronize' &&
113- env. GITHUB_PR_ACTION != ' opened' )
114- {
95+ if (env. GITHUB_PR_ACTION != ' synchronize' && env. GITHUB_PR_ACTION != ' opened' )
11596 error(' Receiving non relevant PR action' )
116- SKIP_PIPELINE = true
117- }
11897 else
11998 {
12099 timeout(time : 30 , unit : ' MINUTES' )
@@ -130,16 +109,13 @@ pipeline
130109 }
131110 // Invalid github event
132111 else if (env.X_GitHub_Event != null )
133- {
134112 error(" Invalid github event: ${ env.X_GitHub_Event} " )
135- }
136113
137114 echo " TARGET_REF: ${ TARGET_REF} "
138115 echo " env.TARGET_REF: ${ env.TARGET_REF} "
139116 echo " TARGET_URL: ${ TARGET_URL} "
140117 echo " REPO_OWNER: ${ REPO_OWNER} "
141118 echo " REPO_NAME: ${ REPO_NAME} "
142- echo " SKIP_PIPELINE: ${ SKIP_PIPELINE} "
143119 echo " STATUS_CONTEXT_URL: ${ STATUS_CONTEXT_URL} "
144120 echo " STORE_BUILD: ${ STORE_BUILD} "
145121 }
@@ -149,7 +125,6 @@ pipeline
149125 stage(' Checkout' )
150126 {
151127 agent { label ' linux' }
152- when { expression { SKIP_PIPELINE == false } }
153128 steps
154129 {
155130 cleanWs()
@@ -175,7 +150,8 @@ pipeline
175150
176151 if (! STORE_BUILD )
177152 {
178- withCredentials([string(credentialsId : ' github-token' , variable : ' GITHUB_TOKEN' )])
153+ withCredentials([string(credentialsId : ' github-token' ,
154+ variable : ' GITHUB_TOKEN' )])
179155 {
180156 SetGithubStatus (' $GITHUB_TOKEN' ,
181157 " Build ${ BUILD_NUMBER} " ,
@@ -196,7 +172,6 @@ pipeline
196172
197173 stage(' Build' )
198174 {
199- when { expression { SKIP_PIPELINE == false } }
200175 parallel
201176 {
202177 stage(' Linux Build' )
@@ -235,7 +210,6 @@ pipeline
235210
236211 stage(' Test' )
237212 {
238- when { expression { SKIP_PIPELINE == false } }
239213 parallel
240214 {
241215 stage(' Linux Test' )
@@ -270,7 +244,7 @@ pipeline
270244 stage(' Notify' )
271245 {
272246 agent { label ' linux' }
273- when { expression { SKIP_PIPELINE == false && STORE_BUILD == false } }
247+ when { expression { STORE_BUILD == false } }
274248 steps
275249 {
276250 cleanWs()
@@ -291,22 +265,22 @@ pipeline
291265 stage(' Release' )
292266 {
293267 agent { label ' linux' }
294- when { expression { SKIP_PIPELINE == false && STORE_BUILD == true } }
268+ when { expression { STORE_BUILD == true } }
295269 steps
296270 {
297271 cleanWs()
298272 dir(' WindowsBuild' ) { unstash ' windows_build' }
299273 dir(' LinuxBuild' ) { unstash ' linux_build' }
300274
301- archiveArtifacts artifacts : ' LinuxBuild/Build/runcpp2' ,
302- defaultExcludes : false ,
303- fingerprint : true ,
304- onlyIfSuccessful : true
275+ archiveArtifacts artifacts : ' LinuxBuild/Build/runcpp2' ,
276+ defaultExcludes : false ,
277+ fingerprint : true ,
278+ onlyIfSuccessful : true
305279
306- archiveArtifacts artifacts : ' WindowsBuild/Build/Debug/runcpp2.exe' ,
307- defaultExcludes : false ,
308- fingerprint : true ,
309- onlyIfSuccessful : true
280+ archiveArtifacts artifacts : ' WindowsBuild/Build/Debug/runcpp2.exe' ,
281+ defaultExcludes : false ,
282+ fingerprint : true ,
283+ onlyIfSuccessful : true
310284 }
311285 }
312286 } // stages
0 commit comments