On the road again

The article will show how to install JJB and to create first job template.

Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML or JSON format and uses them to configure Jenkins.

Installation:

virtualenv venv_jjb
cd ./venv_jjb/
source ./bin/activate
pip install jenkins-job-builder

 Create JJB configuration file (e.g.: jjb.conf:

[jenkins]
query_plugins_info=False
user=<JENKINS_USER>
password=<JENKINS_TOKEN>
url=http://127.0.0.1:8080

Make sure user, token and Jenkins URL are set according to your environment. To get the API token for the logged user, navigate to Jenkins > People > Your User > Configure:

jjb_01.png

 Create directory structure with files to create job template:

jobs

|-template.yaml

|- openstack-artifacts

  |- openstack-tempest.yml-src

 

File contents. Template.yaml:

- job-template:
    # template specific defaults
    command: 'ls -al ~'
    type: freestyle
    # template settings
    name: '{name}'
    builders:
      - shell: '{command}'
    parameters:
    - string:
        name: message
        default: Hello World
    - text:
        name: TEST_SCHEMAS
        description: "JSON string to define testSchemas"
        default:
          !include-jinja2: ./openstack-artifacts/openstack-tempest.yml-src
- project:
    name: basic job
    openstack_run_smoke: true
    openstack_run_full: true
    dashboard_selenium_enabled: true
    openstack_run_ironic: false
    advanced_compute_numa_enabled: true
    advanced_compute_hugepages_enabled: true
    advanced_compute_dpdk_enabled: true
    openstack_version: ussuri
    openstack_context_name: core-ceph-local-non-dvr
    job_suffix: '-advanced-compute'
    threshold_pass: 99
    command: 'ls -al /proc'
    jobs:
      - '{name}'

 openstack-tempest.yml-src:

{%- if openstack_run_smoke -%}
- concurrency: 4
  enabled: true
  blacklist-file: /etc/tempest/test-blacklist
  test_model: "{{ openstack_version }}-{{ openstack_context_name }}{{ job_suffix }}"
{%- endif %}
{%- if openstack_run_full %}
- regex: test
  enabled: true
  concurrency: 4
  testrail: true
  blacklist-file: /etc/tempest/test-blacklist
  tempest_wait_retries: 400
  test_pass_threshold: {{ threshold_pass }}
  openstack_version: "{{ openstack_version }}"
  test_model: "{{ openstack_version }}-{{ openstack_context_name }}{{ job_suffix }}"
{%- endif %}

Run JJB:

jenkins-jobs -l DEBUG --conf ./jjb.conf update jobs
Add comment