jenkins-job-builder/tests/yamlparser/fixtures/variable_default_values.yaml
Thanh Ha 02e85408f0
Fix default '0' being ignored
The problem with `if default:` is that it evaluates int 0 to be
equivalent to False. If a user is passing in a int 0 then they
should be expected to receive int 0 in the case of defaults.

Change-Id: Ida1f4c68b6f9d1af5b98d633b552f038c57654cc
Signed-off-by: Thanh Ha <zxiiro@linux.com>
2018-12-05 17:59:12 +08:00

32 lines
840 B
YAML

- project:
name: test_variable_default_values
jobs:
- 'variable_default_values':
defined_var: '7'
- 'test_int_default_{int}':
int: 0
- 'test_int_default_{int}':
int: 1
- job-template:
name: 'variable_default_values'
properties:
- build-discarder:
days-to-keep: '{undefined_var|+1}'
num-to-keep: '{defined_var|+1}'
artifact-days-to-keep: '{undefined_var|-1}'
artifact-num-to-keep: '{defined_var|-1}'
builders:
- shell: |
echo "{{defined_var|+1}}"
echo "{{defined_var|-1}}"
echo "{{undefined_var|+1}}"
echo "{{undefined_var|-1}}"
- job-template:
name: 'test_int_default_{int}'
parameters:
- string:
name: INT_DEFAULT
default: '{int}'