jervis icon indicating copy to clipboard operation
jervis copied to clipboard

Conditional matrix building and optional build project stage

Open samrocketman opened this issue 3 years ago • 1 comments

Tasks

  • [x] Filter support with filter tests
  • [ ] Implementation
  • [ ] Documentation
  • [ ] Tests

Defining pipeline context

A pipeline context is the conditions in which a job was built or triggered. For example,

Triggers:

  • Manual trigger
  • Cron trigger
  • PR comment trigger
  • Push trigger

Environment context based on Git workflow:

  • Pull request
  • Branch
  • Tag

Conditional disabling "Build Project"

Also, Matrix building of "Build Project" should be conditional

Support for disabling matrix building based on pipeline context. isBuilding() pipeline step should be internalized into Jervis so that it can be used for filtering. It should be extended so that PR comments are also supported.

build:
  on:
    - pr
    - tag
matrix:
  on:
    pr_comment: '/.*[Bb]uild +[Pp](ull +)?[Rr](equest)? +[Mm]atrix.*/'

The filtering should be context aware and Jervis should be instantiated by loading in the context of the pipeline in which it is building.

Support for disabling building

Add support for

build:
  on: 'never'
jenkins:
  pipeline_jenkinsfile: '.ci/Jenkinsfile'

The following would also produce not ever building.

language: groovy
install: true
script: /bin/true
jenkins:
  pipeline_jenkinsfile: '.ci/Jenkinsfile'

Because it is possible a user only wishes to use Jervis for toolchains and any building would happen in their Jenkinsfile.

A user overriding the install and script for a language to execute the documented no-op build means they only want the toolchains for that given language. to

samrocketman avatar Dec 07 '22 00:12 samrocketman

  • Added a new class FilterByContext which provides all of the flexible filtering required for this feature.
  • Added a new var getBuildContextMap() which returns the context of the build environment to be acted on.
  • Updated isBuilding to use the new filtering class.

https://github.com/samrocketman/jervis/compare/0f1c19f7571d035ed690c830168f9b8249057f2e...5bba645ace3aa84c10be78b1ec815fcca429a341

samrocketman avatar Dec 09 '22 12:12 samrocketman