Skip to content

Commit b2dc9e5

Browse files
authored
Merge pull request #415 from chmouel/documentation-grab-all
2 parents 4b3b66c + 628df42 commit b2dc9e5

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

docs/cli.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,25 @@ It has some basic language detection and add extra task depending of the languag
9393

9494
### Resolve
9595

96-
`tkn-pac resolve`: will run a pipelinerun as if it were executed by pipelines as code on service. It will try to detect the current git information if you run the command from your source code. To make it works you need to push the current revision to the target git repository and iterate the pipelinerun change with the `tkn-pac resolve` command. For example if you have a pipelinerun in the `.tekton/pull-request.yaml` file you can run the command `tkn-pac resolve` to see it running:
96+
`tkn-pac resolve`: will run a pipelinerun as if it were executed by pipelines
97+
as code on service.
98+
99+
For example if you have a pipelinerun in the `.tekton/pull-request.yaml` file you can run the command `tkn-pac resolve` to see it running:
97100

98101
```yaml
99102
tkn pac resolve -f .tekton/pull-request.yaml|kubectl apply -f -
100103
```
101104

102105
Combined with a kubernetes install running on your local machine (like[Code Ready Containers](https://developers.redhat.com/products/codeready-containers/overview) or [Kubernetes Kind](https://kind.sigs.k8s.io/docs/user/quick-start/) ) you can see your run in action without having to generate a new commit.
106+
107+
If you run the command from your source code repository it will try to detect the current git information and resolve the parameters like current revision or branch. You can override those params with the `-p` option. For example if you want to use a git branch as revision and another repo name than the current repo name you can just use :
108+
109+
`tkn pac resolve -f .tekton/pr.yaml -p revision=main -p repo_name=othername`
110+
111+
`-f` can as well accept a directory path instead of just a filename and grab every `yaml`/`yml` from the directory.
112+
113+
You can specify multiple `-f` on the command line.
114+
115+
You need to make sure that git-clone task (if you use it) can access the repository to the SHA. Which mean if you test your current source code you need to push it first tbefore using `tkn pac resolve|kubectl apply`.
116+
117+
Compared with running directly on CI, you need to explicitely specify the list of filenames or directory where you have the templates.

docs/guide.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The purposes of the Repository CRD is :
1313

1414
The flow looks like this :
1515

16-
Via the tkn pac CLI or other method the user creates a `Repository` CR
16+
Via the tkn pac CLI or other method the user creates a `Repository` CR
1717
inside the target namespace `my-pipeline-ci` :
1818

1919
```yaml
@@ -244,6 +244,9 @@ Everything that runs your pipelinerun and its references need to be inside the
244244
`.tekton/` directory or referenced via a remote task (see below on how the
245245
remote tasks are referenced).
246246

247+
If you have a taskRef to a task located in the `.tekton/` directory it will be
248+
automatically embedded even if it's not in the annotations.
249+
247250
If pipelines as code cannot resolve the referenced tasks in the `Pipeline` or
248251
`PipelineSpec` it will fails before applying the pipelinerun onto the cluster.
249252

@@ -287,7 +290,7 @@ example :
287290
```yaml
288291
pipelinesascode.tekton.dev/task: "git-clone"
289292
pipelinesascode.tekton.dev/task-1: "golang-test"
290-
pipelinesascode.tekton.dev/task-2: "tkn"
293+
pipelinesascode.tekton.dev/task-2: "tkn"
291294
```
292295

293296
By default `Pipelines as Code` will interpret the string as the `latest` task to

pkg/resolve/resolve_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ func TestNotKubernetesDocumentIgnore(t *testing.T) {
163163
assert.Assert(t, resolved.Spec.PipelineSpec != nil)
164164
}
165165

166+
// test if we have the task in .tekton dir not referenced in annotations but taskRef in a task.
167+
// should embed since in repo.
168+
func TestInRepoShouldNotEmbedIfNoAnnotations(t *testing.T) {
169+
resolved, _, err := readTDfile(t, "in-repo-in-ref-no-annotation", false, true)
170+
assert.NilError(t, err)
171+
assert.Assert(t, resolved.Spec.PipelineSpec.Tasks[0].TaskRef == nil, "task should have been embedded")
172+
}
173+
166174
func TestNoPipelineRuns(t *testing.T) {
167175
_, _, err := readTDfile(t, "no-pipelinerun", false, true)
168176
assert.Error(t, err, "we need at least one pipelinerun to start with")
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
apiVersion: tekton.dev/v1beta1
3+
kind: PipelineRun
4+
metadata:
5+
name: pr
6+
spec:
7+
pipelineRef:
8+
name: pipeline-test
9+
params:
10+
- name: key
11+
value: "{{value}}"
12+
---
13+
apiVersion: tekton.dev/v1beta1
14+
kind: Pipeline
15+
metadata:
16+
name: pipeline-test
17+
spec:
18+
params:
19+
- name: repo_url
20+
- name: revision
21+
tasks:
22+
- name: task
23+
taskRef:
24+
name: should-expand
25+
steps:
26+
- name: first-step
27+
image: image
28+
---
29+
apiVersion: tekton.dev/v1beta1
30+
kind: Task
31+
metadata:
32+
name: should-expand
33+
spec:
34+
steps:
35+
- name: second-step
36+
image: image

0 commit comments

Comments
 (0)