[OpenStack-Infra] [jenkins-job-builder] Default values for macros?

Ben Fox-Moore ben.foxmoore at accelleran.com
Fri Jun 16 17:51:06 UTC 2017


Is it possible to set default values for macros, in a similar way to how
job-templates work? For example, this job-template allows you to override
the 'target' variable, but also has a default value of 'World':

- job-template:
    target: 'World'
    name: 'hello-{target}'
    builders:
      - shell: 'echo "Hello, {target}!"'

- project:
    name: 'example'
    jobs:
      - 'hello-{target}'
      - 'hello-{target}':
          target: 'User'

Unfortunately, this doesn't seem to work with macros. I'm trying to
configure a Git SCM, which has a default branch (master) but can also be
overridden. I've tried a similar approach as above:

- scm:
    name: example
    branches:
      - master
    scm:
      - git:
          url: git at github.com:user/example.git
          branches: '{branches}'

In this case, passing a branches value works, but the default isn't used if
no variable is passed. (Instead '{branches}' is split into individual
characters!)

I've also tried using a custom 'defaults' but the same behaviour occurs as
above.

If this isn't currently possible, does anyone have insight into how difficult
this might be to add. Would a patch for such functionality be welcomed?

Ben



More information about the OpenStack-Infra mailing list