@@ -13,7 +13,7 @@ void createCluster(String CLUSTER_SUFFIX) {
13
13
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
14
14
gcloud config set project $GCP_PROJECT
15
15
gcloud container clusters list --filter $CLUSTER_NAME -${ CLUSTER_SUFFIX} --zone $region --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $region --quiet || true
16
- gcloud container clusters create --zone $region $CLUSTER_NAME -${ CLUSTER_SUFFIX} --cluster-version=1.28 --machine-type=n1-standard-4 --preemptible --disk-size 30 --num-nodes=\$ NODES_NUM --network=jenkins-vpc --subnetwork=jenkins-${ CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 --enable-ip-alias --workload-pool=cloud-dev-112233.svc.id.goog && \
16
+ gcloud container clusters create --zone $region $CLUSTER_NAME -${ CLUSTER_SUFFIX} --cluster-version=1.29 --machine-type=n1-standard-4 --preemptible --disk-size 30 --num-nodes=\$ NODES_NUM --network=jenkins-vpc --subnetwork=jenkins-${ CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 --enable-ip-alias --workload-pool=cloud-dev-112233.svc.id.goog && \
17
17
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT ".iam.gserviceaccount.com || ret_val=\$ ?
18
18
if [ \$ {ret_val} -eq 0 ]; then break; fi
19
19
ret_num=\$ ((ret_num + 1))
@@ -280,58 +280,65 @@ void checkE2EIgnoreFiles() {
280
280
}
281
281
282
282
def e2eignoreFile = " .e2eignore"
283
- if (fileExists(e2eignoreFile)) {
284
- def excludedFiles = readFile(e2eignoreFile). split(' \n ' ). collect{it. trim()}
285
- def lastProcessedCommitFile= " last-processed-commit.txt"
286
- def lastProcessedCommitHash = " "
287
-
288
- def build = currentBuild. previousBuild
289
- while (build != null ) {
290
- try {
291
- echo " Checking previous build: #$build . number "
292
- copyArtifacts(projectName : env. JOB_NAME , selector : specific(" $build . number " ), filter : lastProcessedCommitFile)
293
- lastProcessedCommitHash = readFile(lastProcessedCommitFile). trim()
294
- echo " Last processed commit hash: $lastProcessedCommitHash "
295
- break
296
- } catch (Exception e) {
297
- echo " No $lastProcessedCommitFile found in build $build . number . Checking earlier builds."
298
- }
299
- build = build. previousBuild
283
+ if ( ! fileExists(e2eignoreFile) ) {
284
+ echo " No $e2eignoreFile file found. Proceeding with execution."
285
+ return
286
+ }
287
+
288
+ def excludedFiles = readFile(e2eignoreFile). split(' \n ' ). collect{it. trim()}
289
+ def lastProcessedCommitFile = " last-processed-commit.txt"
290
+ def lastProcessedCommitHash = " "
291
+
292
+ def build = currentBuild. previousBuild
293
+ while (build != null ) {
294
+ try {
295
+ echo " Checking previous build: #$build . number "
296
+ copyArtifacts(projectName : env. JOB_NAME , selector : specific(" $build . number " ), filter : lastProcessedCommitFile)
297
+ lastProcessedCommitHash = readFile(lastProcessedCommitFile). trim()
298
+ echo " Last processed commit hash: $lastProcessedCommitHash "
299
+ break
300
+ } catch (Exception e) {
301
+ echo " No $lastProcessedCommitFile found in build $build . number . Checking earlier builds."
300
302
}
303
+ build = build. previousBuild
304
+ }
301
305
302
- if (lastProcessedCommitHash == " " ) {
303
- echo " This is the first run. Using merge base as the starting point for the diff."
304
- changedFiles = sh(script : " git diff --name-only \$ (git merge-base HEAD origin/$CHANGE_TARGET )" , returnStdout : true ). trim(). split(' \n ' ). findAll{it}
305
- } else {
306
+ if (lastProcessedCommitHash == " " ) {
307
+ echo " This is the first run. Using merge base as the starting point for the diff."
308
+ changedFiles = sh(script : " git diff --name-only \$ (git merge-base HEAD origin/$CHANGE_TARGET )" , returnStdout : true ). trim(). split(' \n ' ). findAll{it}
309
+ } else {
310
+ def commitExists = sh(script : " git cat-file -e $lastProcessedCommitHash 2>/dev/null" , returnStatus : true ) == 0
311
+ if (commitExists) {
306
312
echo " Processing changes since last processed commit: $lastProcessedCommitHash "
307
313
changedFiles = sh(script : " git diff --name-only $lastProcessedCommitHash HEAD" , returnStdout : true ). trim(). split(' \n ' ). findAll{it}
314
+ } else {
315
+ echo " Commit hash $lastProcessedCommitHash does not exist in the current repository. Using merge base as the starting point for the diff."
316
+ changedFiles = sh(script : " git diff --name-only \$ (git merge-base HEAD origin/$CHANGE_TARGET )" , returnStdout : true ). trim(). split(' \n ' ). findAll{it}
308
317
}
318
+ }
309
319
310
- echo " Excluded files: $excludedFiles "
311
- echo " Changed files: $changedFiles "
320
+ echo " Excluded files: $excludedFiles "
321
+ echo " Changed files: $changedFiles "
312
322
313
- def excludedFilesRegex = excludedFiles. collect{it. replace(" **" , " .*" ). replace(" *" , " [^/]*" )}
314
- needToRunTests = ! changedFiles. every{changed -> excludedFilesRegex. any{regex -> changed ==~ regex}}
323
+ def excludedFilesRegex = excludedFiles. collect{it. replace(" **" , " .*" ). replace(" *" , " [^/]*" )}
324
+ needToRunTests = ! changedFiles. every{changed -> excludedFilesRegex. any{regex -> changed ==~ regex}}
315
325
316
- if (needToRunTests) {
317
- echo " Some changed files are outside of the e2eignore list. Proceeding with execution."
326
+ if (needToRunTests) {
327
+ echo " Some changed files are outside of the e2eignore list. Proceeding with execution."
328
+ } else {
329
+ if (currentBuild. previousBuild?. result != ' SUCCESS' ) {
330
+ echo " All changed files are e2eignore files, and previous build was unsuccessful. Propagating previous state."
331
+ currentBuild. result = currentBuild. previousBuild?. result
332
+ error " Skipping execution as non-significant changes detected and previous build was unsuccessful."
318
333
} else {
319
- if (currentBuild. previousBuild?. result in [' FAILURE' , ' ABORTED' , ' UNSTABLE' ]) {
320
- echo " All changed files are e2eignore files, and previous build was unsuccessful. Propagating previous state."
321
- currentBuild. result = currentBuild. previousBuild?. result
322
- error " Skipping execution as non-significant changes detected and previous build was unsuccessful."
323
- } else {
324
- echo " All changed files are e2eignore files. Aborting pipeline execution."
325
- }
334
+ echo " All changed files are e2eignore files. Aborting pipeline execution."
326
335
}
327
-
328
- sh """
329
- echo \$ (git rev-parse HEAD) > $lastProcessedCommitFile
330
- """
331
- archiveArtifacts " $lastProcessedCommitFile "
332
- } else {
333
- echo " No $e2eignoreFile file found. Proceeding with execution."
334
336
}
337
+
338
+ sh """
339
+ echo \$ (git rev-parse HEAD) > $lastProcessedCommitFile
340
+ """
341
+ archiveArtifacts " $lastProcessedCommitFile "
335
342
}
336
343
337
344
def isPRJob = false
0 commit comments