2020-07-06 09:10:11 +00:00
|
|
|
# Git Task
|
|
|
|
|
|
|
|
This `Task` is Git task to work with repositories used by other tasks
|
|
|
|
in your Pipeline.
|
|
|
|
|
|
|
|
## `git-cli`
|
|
|
|
|
2020-07-14 14:42:43 +00:00
|
|
|
This [task](../0.1/git-cli.yaml) can be used to perform `git operations`.
|
2020-07-06 09:10:11 +00:00
|
|
|
All git commands can be found [here](https://git-scm.com/docs).
|
|
|
|
|
|
|
|
Command that needs to be run can be passed as a script to the task.
|
|
|
|
|
|
|
|
### Workspaces
|
|
|
|
|
|
|
|
* **source**: A workspace that contains the fetched git repository.
|
|
|
|
* **input**: A workspace that contains file that needs to be added to git.
|
|
|
|
|
|
|
|
### Parameters
|
|
|
|
|
2020-09-16 13:05:56 +00:00
|
|
|
* **BASE_IMAGE**: The base image for the task.
|
2020-07-06 09:10:11 +00:00
|
|
|
(_default_: `alpine/git:latest`)
|
|
|
|
* **GIT_USER_NAME**: Git user name for performing git operation.
|
|
|
|
* **GIT_USER_EMAIL**: Git user email for performing git operation.
|
|
|
|
* **GIT_SCRIPT**: The git script to run. (_required_)
|
|
|
|
|
|
|
|
### Results
|
|
|
|
|
|
|
|
* **commit**: The precise commit SHA after git operation is performed.
|
|
|
|
|
2021-07-22 13:53:51 +00:00
|
|
|
### Platforms
|
|
|
|
|
|
|
|
The Task can be run on `linux/amd64`, `linux/s390x` and `linux/ppc64le` platforms.
|
|
|
|
|
2020-07-06 09:10:11 +00:00
|
|
|
### Usage
|
|
|
|
|
|
|
|
This task needs authentication to git in order to push after the git operation.
|
|
|
|
This can be done via `secrets` and `service account`.
|
2021-05-21 14:51:13 +00:00
|
|
|
Refer [this](./samples/secret.yaml)
|
2020-07-06 09:10:11 +00:00
|
|
|
example to create secret and service account for the git authentication.
|
|
|
|
|
|
|
|
After creating the task, you should now be able to execute `git` commands by
|
|
|
|
specifying the command you would like to run as the `GIT_SCRIPT` param.
|
|
|
|
|
|
|
|
`Example`:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
params:
|
|
|
|
- name: GIT_SCRIPT
|
|
|
|
value: |
|
|
|
|
git init
|
|
|
|
git remote add origin https://github.com/kelseyhightower/nocode
|
|
|
|
git pull origin master
|
|
|
|
```
|
2021-05-21 14:51:13 +00:00
|
|
|
[Git Pipeline](../0.1/samples/pipeline.yaml) can be referred to use
|
2020-07-06 09:10:11 +00:00
|
|
|
this task in the pipeline.
|
|
|
|
|
|
|
|
**NOTE**
|
|
|
|
|
|
|
|
* If `two factor authentication` is enabled in your git account, then
|
|
|
|
`access-token` for the respective git platform must be provided
|
|
|
|
in the `password` field while adding secrets.
|