Python Jobs¶
Job Groups¶
Job groups are a great tool to configure categories of jobs together at the same time. Below the example are some starting point job-groups but we recommend creating your own to ensure that the jobs configured reflect the project’s needs.
An example project:
- job-group:
name: odl-maven-jobs
jobs:
- gerrit-maven-clm
- gerrit-maven-merge
- gerrit-maven-release
- gerrit-maven-verify
- gerrit-maven-verify-dependencies:
build-timeout: 180
mvn-version: mvn35
- project:
name: aaa
jobs:
- odl-maven-jobs
In this example we are using the job-group to assign a list of common jobs to
the aaa project. The job-group also hardcodes mvn-version
to mvn35 and
build-timeout
to 180 for all projects using this job-group.
A benefit of this method is for example disabling entire category of jobs by
modifying the job-group, insert disable-job: true
parameter
against the jobs to disable.
Below is a list of Maven job groups:
---
- job-group:
name: "{project-name}-python-jobs"
# This job group contains all the recommended jobs that should be deployed
# for any project ci that is using Gerrit.
jobs:
- gerrit-python-xc-clm
- gerrit-tox-verify
- gerrit-tox-merge
- job-group:
name: "{project-name}-github-python-jobs"
# This job group contains all the recommended jobs that should be deployed
# for any project ci that is using GitHub.
jobs:
- github-python-xc-clm
- github-tox-verify
- github-tox-merge
Macros¶
lf-infra-clm-python¶
Run CLM scanning against a Python project.
Required Parameters: | |||||
---|---|---|---|---|---|
|
lf-infra-tox-install¶
Install Tox into a virtualenv.
Required Parameters: | |||
---|---|---|---|
|
lf-tox-install¶
Runs a shell script that installs tox in a Python virtualenv.
Required Parameters: | |||
---|---|---|---|
|
Job Templates¶
Python XC CLM¶
CLM scans for Python based repos. This job will call the Nexus IQ CLI directly to run the scans.
A new credential named “nexus-iq-xc-clm” needs to exist in the Jenkins credentials. The credential should contain the username and password to access Nexus IQ Server.
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||||||
run-clm |
|||||||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||||||
|
Python Sonar with Tox¶
Sonar scans for Python based repos. This job invokes tox to run tests and gather coverage statistics from the test results, then invokes Maven to publish the results to a Sonar server.
To get the Sonar coverage results, file tox.ini must exist and contain coverage commands to run.
The coverage commands define the code that gets executed by the test suites. Checking coverage does not guarantee that the tests execute properly, but it identifies code that is not executed by any test.
This job reuses the Sonar builder used in Java/Maven projects which runs maven twice. The first invocation does nothing for Python projects, so the job uses the goal ‘validate’ by default. The second invocation publishes results using the goal ‘sonar:sonar’ by default.
For example:
[testenv:py27]
commands =
coverage run --module pytest --junitxml xunit-results.xml
coverage xml --omit=".tox/py27/*","tests/*"
coverage report --omit=".tox/py27/*","tests/*"
For more details refer to coverage and sonar documentation:
https://coverage.readthedocs.io/
https://docs.sonarqube.org/display/PLUG/Python+Coverage+Results+Import
Template Names: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
run-sonar |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Required parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Optional parameters: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Tox Verify¶
Tox runner to verify a project on creation of a patch set. This job is pyenv aware so if the image contains an installation of pyenv at /opt/pyenv it will pick it up and run Python tests with the appropriate Python versions. This job will set the following pyenv variables before running.
export PYENV_ROOT="/opt/pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
Template Names: |
|
||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||
recheck|reverify |
|||||||||||||||||||||||||||||||||||||||
Required Parameters: | |||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||
Optional Parameters: | |||||||||||||||||||||||||||||||||||||||
|
Tox Merge¶
Tox runner to verify a project after merge of a patch set. This job is pyenv aware so if the image contains an installation of pyenv at /opt/pyenv it will pick it up and run Python tests with the appropriate Python versions. This job will set the following pyenv variables before running.
export PYENV_ROOT="/opt/pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
Template Names: |
|
||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Comment Trigger: | |||||||||||||||||||||||||||||||||||||||
remerge |
|||||||||||||||||||||||||||||||||||||||
Required Parameters: | |||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||
Optional Parameters: | |||||||||||||||||||||||||||||||||||||||
|