Skip to content
Snippets Groups Projects
Unverified Commit 90d9cd7d authored by Fabian Heib's avatar Fabian Heib Committed by GitHub
Browse files

feat(tekton): support pipelinesascode annotation (#26753)

parent 5de12e7f
No related branches found
No related tags found
No related merge requests found
...@@ -4,18 +4,22 @@ metadata: ...@@ -4,18 +4,22 @@ metadata:
annotations: annotations:
pipelinesascode.tekton.dev/on-event: "[pull_request]" pipelinesascode.tekton.dev/on-event: "[pull_request]"
pipelinesascode.tekton.dev/task: "[git-clone,https://github.com/foo/bar/releases/download/v0.0.4/stakater-create-git-tag.yaml]" pipelinesascode.tekton.dev/task: "[git-clone,https://github.com/foo/bar/releases/download/v0.0.4/stakater-create-git-tag.yaml]"
pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/foo/baz/v0.0.12/pipeline/deploy/deploy.yaml"
--- ---
kind: PipelineRun kind: PipelineRun
metadata: metadata:
annotations: annotations:
pipelinesascode.tekton.dev/task: "[git-clone, pipelinesascode.tekton.dev/task: "[git-clone,
https://raw.githubusercontent.com/foo/bar/v0.0.6/tasks/create-git-tag/create-git-tag.yaml]" https://raw.githubusercontent.com/foo/bar/v0.0.6/tasks/create-git-tag/create-git-tag.yaml]"
pipelinesascode.tekton.dev/pipeline: "
https://raw.githubusercontent.com/foo/baz/v0.0.12/pipeline/deploy/deploy.yaml"
--- ---
kind: PipelineRun kind: PipelineRun
metadata: metadata:
annotations: annotations:
pipelinesascode.tekton.dev/task: "git-clone" pipelinesascode.tekton.dev/task: "git-clone"
pipelinesascode.tekton.dev/task-1: "https://github.com/foo/bar/raw/v0.0.8/tasks/create-git-tag/create-git-tag.yaml" pipelinesascode.tekton.dev/task-1: "https://github.com/foo/bar/raw/v0.0.8/tasks/create-git-tag/create-git-tag.yaml"
pipelinesascode.tekton.dev/pipeline: "https://github.com/foo/baz/raw/v0.0.14/pipeline/deploy/deploy.yaml"
--- ---
kind: PipelineRun kind: PipelineRun
metadata: metadata:
...@@ -24,3 +28,4 @@ metadata: ...@@ -24,3 +28,4 @@ metadata:
https://github.com/foo/bar/releases/download/v0.0.9/stakater-create-git-tag.yaml, https://github.com/foo/bar/releases/download/v0.0.9/stakater-create-git-tag.yaml,
https://github.com/foo/bar/raw/v0.0.7/tasks/create-git-tag/create-git-tag.yaml, https://github.com/foo/bar/raw/v0.0.7/tasks/create-git-tag/create-git-tag.yaml,
https://raw.githubusercontent.com/foo/bar/v0.0.5/tasks/create-git-tag/create-git-tag.yaml]" https://raw.githubusercontent.com/foo/bar/v0.0.5/tasks/create-git-tag/create-git-tag.yaml]"
pipelinesascode.tekton.dev/pipeline: "https://raw.githubusercontent.com/foo/baz/v0.0.25/pipeline/deploy/deploy.yaml"
...@@ -26,6 +26,13 @@ describe('modules/manager/tekton/extract', () => { ...@@ -26,6 +26,13 @@ describe('modules/manager/tekton/extract', () => {
depType: 'tekton-annotation', depType: 'tekton-annotation',
packageName: 'foo/bar', packageName: 'foo/bar',
}, },
{
currentValue: 'v0.0.12',
datasource: 'git-tags',
depName: 'github.com/foo/baz',
depType: 'tekton-annotation',
packageName: 'https://github.com/foo/baz',
},
{ {
currentValue: 'v0.0.6', currentValue: 'v0.0.6',
datasource: 'git-tags', datasource: 'git-tags',
...@@ -33,6 +40,13 @@ describe('modules/manager/tekton/extract', () => { ...@@ -33,6 +40,13 @@ describe('modules/manager/tekton/extract', () => {
depType: 'tekton-annotation', depType: 'tekton-annotation',
packageName: 'https://github.com/foo/bar', packageName: 'https://github.com/foo/bar',
}, },
{
currentValue: 'v0.0.12',
datasource: 'git-tags',
depName: 'github.com/foo/baz',
depType: 'tekton-annotation',
packageName: 'https://github.com/foo/baz',
},
{ {
currentValue: 'v0.0.8', currentValue: 'v0.0.8',
datasource: 'git-tags', datasource: 'git-tags',
...@@ -40,6 +54,13 @@ describe('modules/manager/tekton/extract', () => { ...@@ -40,6 +54,13 @@ describe('modules/manager/tekton/extract', () => {
depType: 'tekton-annotation', depType: 'tekton-annotation',
packageName: 'https://github.com/foo/bar', packageName: 'https://github.com/foo/bar',
}, },
{
currentValue: 'v0.0.14',
datasource: 'git-tags',
depName: 'github.com/foo/baz',
depType: 'tekton-annotation',
packageName: 'https://github.com/foo/baz',
},
{ {
currentValue: 'v0.0.9', currentValue: 'v0.0.9',
datasource: 'github-releases', datasource: 'github-releases',
...@@ -61,6 +82,13 @@ describe('modules/manager/tekton/extract', () => { ...@@ -61,6 +82,13 @@ describe('modules/manager/tekton/extract', () => {
depType: 'tekton-annotation', depType: 'tekton-annotation',
packageName: 'https://github.com/foo/bar', packageName: 'https://github.com/foo/bar',
}, },
{
currentValue: 'v0.0.25',
datasource: 'git-tags',
depName: 'github.com/foo/baz',
depType: 'tekton-annotation',
packageName: 'https://github.com/foo/baz',
},
], ],
}); });
}); });
......
...@@ -86,7 +86,9 @@ function getDeps(doc: TektonResource): PackageDependency[] { ...@@ -86,7 +86,9 @@ function getDeps(doc: TektonResource): PackageDependency[] {
return deps; return deps;
} }
const taskAnnotation = regEx(/^pipelinesascode\.tekton\.dev\/task(-[0-9]+)?$/); const annotationRegex = regEx(
/^pipelinesascode\.tekton\.dev\/(?:task(-[0-9]+)?|pipeline)$/,
);
function addPipelineAsCodeAnnotations( function addPipelineAsCodeAnnotations(
annotations: Record<string, string> | undefined | null, annotations: Record<string, string> | undefined | null,
...@@ -97,16 +99,16 @@ function addPipelineAsCodeAnnotations( ...@@ -97,16 +99,16 @@ function addPipelineAsCodeAnnotations(
} }
for (const [key, value] of Object.entries(annotations)) { for (const [key, value] of Object.entries(annotations)) {
if (!taskAnnotation.test(key)) { if (!annotationRegex.test(key)) {
continue; continue;
} }
const tasks = value const values = value
.replace(regEx(/]$/), '') .replace(regEx(/]$/), '')
.replace(regEx(/^\[/), '') .replace(regEx(/^\[/), '')
.split(','); .split(',');
for (const task of tasks) { for (const value of values) {
const dep = getAnnotationDep(task.trim()); const dep = getAnnotationDep(value.trim());
if (!dep) { if (!dep) {
continue; continue;
} }
......
...@@ -17,15 +17,16 @@ Read the [Tekton Pipeline remote resolution docs](https://tekton.dev/docs/pipeli ...@@ -17,15 +17,16 @@ Read the [Tekton Pipeline remote resolution docs](https://tekton.dev/docs/pipeli
### Using a PipelinesAsCode remote URL reference ### Using a PipelinesAsCode remote URL reference
By specifying the annotation with a remote task based on the recommended way using [git based versioning](https://github.com/tektoncd/community/blob/main/teps/0115-tekton-catalog-git-based-versioning.md). How this can be used can be seen in the example below. By specifying the annotation with a remote task or a remote pipeline based on the recommended way using [git based versioning](https://github.com/tektoncd/community/blob/main/teps/0115-tekton-catalog-git-based-versioning.md). How this can be used can be seen in the example below.
```yaml title="How an annotation in could look like in an pipeline-run.yaml" ```yaml title="How an annotation could look like in an pipeline-run.yaml"
apiVersion: tekton.dev/v1 apiVersion: tekton.dev/v1
kind: PipelineRun kind: PipelineRun
metadata: metadata:
name: main name: main
annotations: annotations:
pipelinesascode.tekton.dev/task: 'https://github.com/foo/bar/raw/v0.0.1/tasks/task/task.yaml' pipelinesascode.tekton.dev/task: 'https://github.com/foo/bar/raw/v0.0.1/task/my-task/my-task.yaml'
pipelinesascode.tekton.dev/pipeline: 'https://github.com/foo/bar/raw/v0.0.1/pipeline/my-pipeline/my-pipeline.yaml'
``` ```
Supported URLs: Supported URLs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment