Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
Start using Pipelines as Code Repository defintion (instead of CR)
Document tkn pac repo delete
Move and improve section about gitops comment

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
  • Loading branch information
chmouel committed May 18, 2022
1 parent 79e6111 commit fa1af04
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 44 deletions.
98 changes: 74 additions & 24 deletions docs/content/docs/guide/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ weight: 10
---
# Pipelines as Code CLI

Pipelines as Code provide a powerful CLI designed to work with tkn plug-in. tkn-pac allows you to :
Pipelines as Code provide a powerful CLI designed to work with tkn plug-in. `tkn pac` allows you to :

* `bootstrap`: quickly bootstrap a Pipelines as Code installation.
* `create`: create a new Pipelines as Code Repository.
* `create`: create a new Pipelines as Code Repository definition.
* `delete`: delete an existing Pipelines as Code Repository definition.
* `generate`: generate a simple pipelinerun to get you started with Pipelines as Code.
* `list`: list Pipelines as Code Repositories.
* `describe`: describe a Pipelines as Code Repository and the runs associated with it.
Expand All @@ -29,8 +30,9 @@ Available operating systems are :
* Windows - Arm 64 Bits and x86 architecture.

{{< /tab >}}

{{< tab "Homebrew" >}}
tkn-pac is available from HomeBrew as a "Tap", you simply need to run this command to install it :
tkn pac plug-in is available from HomeBrew as a "Tap", you simply need to run this command to install it :

```shell
brew install openshift-pipelines/pipelines-as-code/tektoncd-pac
Expand All @@ -42,16 +44,16 @@ and if you need to upgrade it :
brew upgrade openshift-pipelines/pipelines-as-code/tektoncd-pac
```

`tkn-pac` is compatible with [Homebrew on Linux](https://docs.brew.sh/Homebrew-on-Linux)
`tkn pac` plug-in is compatible with [Homebrew on Linux](https://docs.brew.sh/Homebrew-on-Linux)

{{< /tab >}}
{{< tab "Container" >}}
`tkn-pac` is as a docker container, :
`tkn-pac` is available as a docker container, :

```shell
# use docker
podman run -e KUBECONFIG=/tmp/kube/config -v ${HOME}/.kube:/tmp/kube \
-it quay.io/openshift-pipeline/pipelines-as-code tkn-pac help
-it ghcr.io/openshift-pipelines/pipelines-as-code:stable tkn-pac help
```

{{< /tab >}}
Expand All @@ -66,7 +68,9 @@ go install github.com/openshift-pipelines/pipelines-as-code/cmd/tkn-pac
{{< /tab >}}

{{< tab "Arch" >}}
You can install `tkn-pac` from the [Arch User Repository](https://aur.archlinux.org/packages/tkn-pac/) (AUR) with your favourite AUR installer like `yay` :
You can install the `tkn pac` plugin from the [Arch User
Repository](https://aur.archlinux.org/packages/tkn-pac/) (AUR) with your
favourite AUR installer like `yay` :

```shell
yay -S tkn-pac
Expand All @@ -82,15 +86,21 @@ yay -S tkn-pac

### bootstrap

`tkn pac bootstrap` command will help you to get started installing and configuring Pipelines as code. It currently supports the following providers:
`tkn pac bootstrap` command will help you to get started installing and
configuring Pipelines as code. It currently supports the following providers:

* GitHub Application on public GitHub
* GitHub Application on GitHub Enterprise

It will start checking if you have installed Pipelines as Code and if not it will ask you if you want to install (with `kubectl`) the latest stable release. If you add the flag `--nightly` it will install the latest code ci release.
It will start checking if you have installed Pipelines as Code and if not it
will ask you if you want to install (with `kubectl`) the latest stable
release. If you add the flag `--nightly` it will install the latest code ci
release.

Bootstrap detect the OpenShift Route automatically associated to the Pipelines as code controller service.
If you don't have an OpenShift install it will ask you for your public URL (ie: an ingress spec URL)
Bootstrap detect the OpenShift Route automatically associated to the Pipelines
as code controller service.
If you don't have an OpenShift install it will ask you for your public URL (ie:
an ingress spec URL)
You can override the URL with the flag `--route-url`.
{{< /details >}}

Expand All @@ -110,34 +120,61 @@ GitHub application and the secret with all the information needed in the

### Repository creation

`tkn pac repo create` -- will create a new Pipelines as Code Repository, a namespace where the pipelineruns command and configure webhook. It will also generate a sample file with a [PipelineRun](/docs/guide/authoringprs) in the `.tekton` directory called `pipelinerun.yaml` targeting the `main` branch and the `pull_request` and `push` events. You can customize this by editing the [PipelineRun](/docs/guide/authoringprs) to target a different branch or event.
`tkn pac repo create` -- will create a new Pipelines as Code Repository
definition, a namespace where the pipelineruns command and configure webhook. It
will also generate a sample file with a [PipelineRun](/docs/guide/authoringprs)
in the `.tekton` directory called `pipelinerun.yaml` targeting the `main` branch
and the `pull_request` and `push` events. You can customize this by editing the
[PipelineRun](/docs/guide/authoringprs) to target a different branch or event.

If you haven't configured a provider previously, it will follow up with
questions if you want to configure a webhook for your provider of choice.
{{< /details >}}

{{< details "tkn pac repo delete" >}}

### Repository delete

`tkn pac repo delete` -- will delete a Pipelines as Code Repository definition.

You can specify the flag `--cascade` to optionally delete the attached secrets
(ie: webhook or provider secret) to the Pipelines as Code Repository definition.

If you haven't configured a provider previously, it will follow up with questions if you want to configure a webhook for your provider of choice.
{{< /details >}}

{{< details "tkn pac repo list" >}}

### Repository Listing

`tkn pac repo list` -- will list all the Pipelines as Code Repositories and display the last status of the runs associated with it.
`tkn pac repo list` -- will list all the Pipelines as Code Repositories
definition and display the last status of the runs associated with it.
{{< /details >}}

{{< details "tkn pac repo describe" >}}

### Repository Describe

`tkn pac repo describe` -- will describe a Pipelines as Code Repository and the runs associated with it.
`tkn pac repo describe` -- will describe a Pipelines as Code Repository
definition and the runs associated with it.

On modern terminal (ie: [iTerm2](https://iterm2.com/), [Windows Terminal](https://github.com/microsoft/terminal), GNOME-terminal and so on...) the links are clickable with control+click or ⌘+click and will open the browser to the UI URL to see the Pipelinerun associated with it.
On modern terminal (ie: [iTerm2](https://iterm2.com/), [Windows
Terminal](https://github.com/microsoft/terminal), GNOME-terminal and so on...)
the links are clickable with control+click or ⌘+click and will open the browser
to the UI URL to see the Pipelinerun associated with it.
{{< /details >}}

{{< details "tkn pac generate" >}}

### Generate

`tkn pac generate`: will generate a simple pipelinerun to get you started with Pipelines as Code. It will try to be as smart as possible by detecting the current Git information if you run the command from your source code.
`tkn pac generate`: will generate a simple pipelinerun to get you started with
Pipelines as Code. It will try to be as smart as possible by detecting the
current Git information if you run the command from your source code.

It has some basic language detection and add extra task depending on the language. For example if it detects a file named `setup.py` at the repository root it will add the [pylint task](https://hub.tekton.dev/tekton/task/pylint) to the generated pipelinerun.
It has some basic language detection and add extra task depending on the
language. For example if it detects a file named `setup.py` at the repository
root it will add the [pylint task](https://hub.tekton.dev/tekton/task/pylint) to
the generated pipelinerun.
{{< /details >}}

{{< details "tkn pac resolve" >}}
Expand All @@ -147,25 +184,38 @@ It has some basic language detection and add extra task depending on the languag
`tkn-pac resolve`: will run a pipelinerun as if it were executed by pipelines
as code on service.

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:
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:

```yaml
tkn pac resolve -f .tekton/pull-request.yaml|kubectl apply -f -
```

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.
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.

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 :
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 :

`tkn pac resolve -f .tekton/pr.yaml -p revision=main -p repo_name=othername`

`-f` can as well accept a directory path rather than just a filename and grab every `yaml`/`yml` from the directory.
`-f` can as well accept a directory path rather than just a filename and grab
every `yaml`/`yml` from the directory.

You can specify multiple `-f` on the command line.

You need to verify 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 before using `tkn pac resolve|kubectl apply`.
You need to verify 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 before using `tkn pac resolve|kubectl apply`.

Compared with running directly on CI, you need to explicitly specify the list of filenames or directory where you have the templates.
Compared with running directly on CI, you need to explicitly specify the list of
filenames or directory where you have the templates.
{{< /details >}}

## Screenshot
Expand Down
38 changes: 38 additions & 0 deletions docs/content/docs/guide/running.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,41 @@ tkn pr logs -n my-pipeline-ci -Lf
Or with the OpenShift console inside your namespace you can follow the
pipelinerun execution with the URL provided on the "Checks" tab if you run with
GitHub App.

## Restarting the PipelineRun

You can restart a PipelineRun without having to send a new commit to
your branch or pull_request.

### Github APPS

On Github if you are using the Github apps, you can go to the Checks tab and
click on the upper left button called "Re-Run" and Pipelines as Code will react
to the event and restart testing the PipelineRun

### Gitops command on pull or merge request

If you are targetting a pull or merge request you can use `GitOps` comment
inside your pull request, to restart all or specific Pipelines.

For example you want to restart all your pipeline you can add a comment starting
with `/retest` and all PipelineRun attached to that pull or merge request will be
restarted :

Example :

```text
Thanks for contributing, This is a much needed bugfix, and we love it ❤️ The
failure is not with your PR but seems to be an infra issue.
/retest
```

If you have multiple `PipelineRun` and you want to target a specific
`PipelineRun` you can use the `/test` comment, example:

```text
roses are red, violets are blue. pipeline are bound to flake by design.
/test <pipelinerun-name>
```
22 changes: 2 additions & 20 deletions docs/content/docs/guide/statuses.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,9 @@ When the pipeline finishes, the status will be added in the GitHub Check tabs
with a short recap of how long each task of your pipeline took and the output of
`tkn pr describe`.

If there was a failure you can click on the "Re-Run" button on the left to rerun
the Pipeline or you can issue an issue comment with a line starting and finishing
with the string `/retest` to ask Pipelines as Code to retest the current PR.
## Webhook

Example :

```text
Thanks for contributing, This is a much needed bugfix, and we love it ❤️ The
failure is not with your PR but seems to be an infra issue.
/retest
```

Note that `/retest` runs every `PipelineRun` matching the Pull Request. If you want to retest an individual `PipelineRun`
you can run it again by adding a comment with `/test <pipelinerun-name>`.

Example:

```yaml
/test <pipelineRun-name>
```
On webhook if it's a pull request

## CRD

Expand Down

0 comments on commit fa1af04

Please sign in to comment.