diff --git a/src/api/pipelineRuns.js b/src/api/pipelineRuns.js index 135730988..7ae90add6 100644 --- a/src/api/pipelineRuns.js +++ b/src/api/pipelineRuns.js @@ -1,5 +1,5 @@ /* -Copyright 2019-2023 The Tekton Authors +Copyright 2019-2024 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -95,8 +95,10 @@ export function getPipelineRunPayload({ timeoutsPipeline, timeoutsTasks }) { + const pipelinesAPIVersion = getTektonPipelinesAPIVersion(); + const payload = { - apiVersion: `tekton.dev/${getTektonPipelinesAPIVersion()}`, + apiVersion: `tekton.dev/${pipelinesAPIVersion}`, kind: 'PipelineRun', metadata: { name: pipelineRunName, @@ -128,7 +130,13 @@ export function getPipelineRunPayload({ }; } if (serviceAccount) { - payload.spec.serviceAccountName = serviceAccount; + if (pipelinesAPIVersion === 'v1') { + payload.spec.taskRunTemplate = { + serviceAccountName: serviceAccount + }; + } else { + payload.spec.serviceAccountName = serviceAccount; + } } if (timeoutsFinally || timeoutsPipeline || timeoutsTasks) { payload.spec.timeouts = { diff --git a/src/api/pipelineRuns.test.js b/src/api/pipelineRuns.test.js index 2396a7f56..e3738d298 100644 --- a/src/api/pipelineRuns.test.js +++ b/src/api/pipelineRuns.test.js @@ -1,5 +1,5 @@ /* -Copyright 2019-2023 The Tekton Authors +Copyright 2019-2024 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -74,7 +74,9 @@ describe('createPipelineRun', () => { name, value: params[name] })), - serviceAccountName: serviceAccount, + taskRunTemplate: { + serviceAccountName: serviceAccount + }, timeouts: { pipeline: timeout } @@ -128,7 +130,9 @@ describe('createPipelineRun', () => { disk: 'ssd' } }, - serviceAccountName: serviceAccount, + taskRunTemplate: { + serviceAccountName: serviceAccount + }, timeouts: { pipeline: timeout }