-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a git task to clone a repository without PipelineResource #123
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Git tasks | ||
|
||
These Tasks are Git tasks to clone a repository in the workspace to be | ||
used by other tasks in a Pipeline. | ||
|
||
This is a `Task` that does the job of the `GitResource` | ||
`PipelineResource`. This is linked to | ||
[tektoncd/pipeline#1369](https://github.com/tektoncd/pipeline/issues/1369). | ||
|
||
## `fetch-git` | ||
|
||
### Inputs | ||
|
||
#### Parameters | ||
|
||
* **url**: git url to clone | ||
* **revision**: git revision to checkout (branch, tag, sha, ref…) (_default:_ master) | ||
* **workingDirectory**: working directory to clone (_default:_ .) | ||
* **submodules**: init and fetch recursively submodules (_default:_ true) | ||
|
||
## Usage | ||
|
||
### `fetch-git` | ||
|
||
This pipeline uses the Task to clone the | ||
[`tektoncd/pipeline`](https://github.com/tektoncd/pipeline) repository | ||
and display the README in the next step | ||
|
||
```yaml | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: cat-readme | ||
spec: | ||
steps: | ||
- name: clone | ||
image: ubuntu | ||
workingdir: /workspace/src/ | ||
command: | ||
- /bin/bash | ||
- -c | ||
args: | ||
- "cat README" | ||
volumeMounts: | ||
- name: source | ||
mountPath: /workspace/src | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: cat-pipeline-readme | ||
spec: | ||
tasks: | ||
- name: fetch-repository | ||
taskRef: | ||
name: fetch-git | ||
params: | ||
- name: url | ||
value: github.com/tektoncd/pipeline | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm running into below error when trying to play around with this locally: |
||
- name: cat-readme | ||
taskRef: | ||
name: echo-readme | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be |
||
``` | ||
|
||
This pipeline can be used as the following `PipelineRun` does. | ||
|
||
```yaml | ||
kind: PersistentVolumeClaim | ||
apiVersion: v1 | ||
metadata: | ||
name: source | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 500Mi | ||
--- | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
name: cat-pipeline-readme-run | ||
spec: | ||
pipelineRef: | ||
name: cat-pipeline-readme | ||
podTemplate: | ||
volumes: | ||
- name: source | ||
persistentVolumeClaim: | ||
claimName: source | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: fetch-git | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about calling this by the git action? i.e: |
||
spec: | ||
inputs: | ||
params: | ||
- name: url | ||
description: git url to clone | ||
type: string | ||
- name: revision | ||
description: git revision to checkout (branch, tag, sha, ref…) | ||
type: string | ||
default: master | ||
- name: workingDirectory | ||
description: working directory to clone | ||
type: string | ||
default: . | ||
- name: submodules | ||
description: init and fetch recursively submodules | ||
type: string | ||
default: "true" | ||
steps: | ||
- name: clone | ||
image: gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:latest | ||
workingdir: /workspace/src/ | ||
command: | ||
- /ko-app/git-init | ||
args: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add the parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @csantanapr yeah we will add support for |
||
- -url | ||
- $(inputs.params.url) | ||
- -revision | ||
- $(inputs.params.revision) | ||
- -path | ||
- $(inputs.params.workingDirectory) | ||
- -submodules | ||
- $(inputs.params.submodules) | ||
stepTemplate: | ||
volumeMounts: | ||
- name: source | ||
mountPath: /workspace/src |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab -> spaces