Skip to content

Commit 411e79f

Browse files
committed
Document run-condition action
Signed-off-by: Nikola Forró <nforro@redhat.com>
1 parent 15805ae commit 411e79f

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

docs/configuration/actions.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ These apply to the `srpm` command and building in COPR.
8989
| [hook] | `post-modifications` | upstream git repo | after all modifications to the spec file and before running rpmbuild command | |
9090
| | `changelog-entry` | upstream git repo | when adding a new changelog entry to the specfile | stdout is used as a changelog entry |
9191

92+
93+
### Job-level actions
94+
95+
| | name | working directory | when run | description |
96+
|--------|-----------------------|-------------------|-----------------------------------------------------------------------|------------------------------------------------------|
97+
| [hook] | `run-condition` | upstream git repo | before a job would run | exit code of this action determines if the job will run |
98+
9299
## Actions details
93100

94101
All actions are executed in a locked-down OpenShift pod. Your commands are
@@ -157,6 +164,34 @@ Our internal API differentiates between the commit title and description, so we
157164
have an additional requirement on separating the commit title by an empty line.
158165
You can, of course, provide *just* the commit title.
159166

167+
### `run-condition`
168+
169+
This action only makes sense at a job level and the exit code of the last command executed
170+
determines if the job will run. If the exit code is non-zero, the job will be skipped.
171+
If [`clone_repos_before_run_condition`](/docs/configuration/#clone_repos_before_run_condition)
172+
is `true`, upstream and/or downstream git repos (depending on the job in question and its trigger)
173+
will be cloned before the action is run.
174+
175+
For example:
176+
177+
```yaml
178+
jobs:
179+
- job: koji_build
180+
trigger: commit
181+
dist-git-branches:
182+
- fedora-all
183+
actions:
184+
run-condition:
185+
# run only if version is not a pre-release
186+
- bash -c 'echo $PACKIT_PROJECT_VERSION | grep -Pvq -- "-(alpha|beta|rc)\d*$"'
187+
```
188+
189+
:::note
190+
191+
The action is currently enabled only for downstream jobs.
192+
193+
:::
194+
160195
#### Debugging
161196

162197
For your own debugging purposes we allow arbitrary output before outputting the
@@ -246,6 +281,12 @@ when syncing upstream release downstream, e.g. `rhbz#123 rhbz#124`
246281
* `PACKIT_RESOLVED_BUGS` - bugs resolved by the release separated by space,
247282
e.g. `rhbz#123 rhbz#124`
248283

284+
### `run-condition`
285+
286+
* `PACKIT_PROJECT_VERSION` — current version of the project
287+
* `PACKIT_UPSTREAM_REPO` — absolute path to cloned upstream git repo, presence depends on context
288+
* `PACKIT_DOWNSTREAM_REPO` — absolute path to cloned downstream git repo, presence depends on context
289+
249290
### Release-synchronization actions
250291

251292
Related to the `propose-downstream` and `pull-from-upstream` jobs.

docs/configuration/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,12 @@ build job statuses. When set to `false`, while test jobs are waiting for their c
765765
to finish, their statuses remain in pending state and only build job statuses are updated, for example with
766766
`SRPM build is in progress...` or `Starting RPM build...`.
767767

768+
#### clone_repos_before_run_condition
769+
770+
(*bool*) When set to `true`, upstream and/or downstream (depending on context) git repos will be cloned
771+
before any configured `run-condition` action is run. The option has no effect if there is no `run-condition`
772+
action configured. Defaults to `false`.
773+
768774
#### osh_diff_scan_after_copr_build
769775

770776
(*bool*) Whether to run a differential scan in [OpenScanHub](https://openscanhub.fedoraproject.org/)

0 commit comments

Comments
 (0)