Add docs for Python XC CLM
[releng/global-jjb.git] / docs / jjb / lf-python-jobs.rst
1 ###########
2 Python Jobs
3 ###########
4
5 Job Groups
6 ==========
7
8 {project-name}-python-jobs
9 --------------------------
10
11 Jobs for Python projects using Gerrit.
12
13 :Includes:
14
15     - gerrit-tox-verify
16
17 {project-name}-github-python-jobs
18 ---------------------------------
19
20 Jobs for Python projects using GitHub.
21
22 :Includes:
23
24     - github-tox-verify
25
26
27 Macros
28 ======
29
30 lf-tox-install
31 --------------
32
33 Runs a shell script that installs tox in a Python virtualenv.
34
35 :Required Parameters:
36
37     :python-version: Base Python version to use in the virtualenv. For example
38         python2 or python3.
39
40
41 Job Templates
42 =============
43
44 Python XC CLM
45 -------------
46
47 CLM scans for Python based repos. This job will call the Nexus IQ CLI
48 directly to run the scans.
49
50 A new credential named "nexus-iq-xc-clm" needs to exist in the Jenkins credentials.
51 The credential should contain the username and password to access Nexus
52 IQ Server.
53
54 :Template Names:
55
56     - {project-name}-python-clm-{stream}
57     - gerrit-python-xc-clm
58     - github-python-xc-clm
59
60 :Required parameters:
61
62     :build-node: The node to run build on.
63     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
64         get configured in defaults.yaml)
65
66 :Optional parameters:
67
68     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
69     :nexus-iq-cli-version: Nexus IQ CLI package version to download and use. (default: 1.44.0-01)
70     :build-timeout: Timeout in seconds before aborting build. (default: 60)
71     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
72     :java-version: Version of Java to use for the build. (default: openjdk8)
73     :stream: Keyword used to represent a release code-name.
74         Often the same as the branch. (default: master)
75     :submodule-recursive: Whether to checkout submodules recursively.
76         (default: true)
77     :gerrit_clm_triggers: Override Gerrit Triggers.
78
79 Python Sonar with Tox
80 ---------------------
81
82 Sonar scans for Python based repos. This job will perform a tox call which
83 runs the coverage command to gather tests results. These test results get
84 published back into Sonar after running the Sonar goals.
85
86 To get the Sonar coverage results, tox.ini needs to exist and configured
87 with coverage commands to run.
88
89 The coverage commands define the code that gets executed by the test suites.
90 It does not guarantee that the code tests executed properly, but it will help
91 pointing out the code that is not tested at all.
92
93 For example:
94
95 .. code-block:: bash
96
97     [testenv:py27]
98     commands =
99             coverage run --module pytest --junitxml xunit-results.xml
100             coverage xml --omit=".tox/py27/*","tests/*"
101             coverage report --omit=".tox/py27/*","tests/*"
102
103 For more details refer to coverage and sonar documentation:
104
105 https://coverage.readthedocs.io/
106
107 https://docs.sonarqube.org/display/PLUG/Python+Coverage+Results+Import
108
109 :Template Names:
110
111     - {project-name}-tox-sonar
112     - gerrit-tox-sonar
113     - github-tox-sonar
114
115 :Required parameters:
116
117     :build-node: The node to run build on.
118     :jenkins-ssh-credential: Credential to use for SSH. (Generally should
119         get configured in defaults.yaml)
120     :mvn-settings: The name of settings file containing credentials for the project.
121
122 :Optional parameters:
123
124     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
125     :build-timeout: Timeout in seconds before aborting build. (default: 60)
126     :cron: Cron schedule when to trigger the job. This parameter also
127         supports multiline input via YAML pipe | character in cases where
128         one may want to provide more than 1 cron timer.  (default: H 11 * * *
129         to run once a day)
130     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
131     :java-version: Version of Java to use for the build. (default: openjdk8)
132     :mvn-global-settings: The name of the Maven global settings to use for
133         Maven configuration. (default: global-settings)
134     :mvn-version: Version of maven to use. (default: mvn33)
135     :stream: Keyword used to represent a release code-name.
136         Often the same as the branch. (default: master)
137     :submodule-recursive: Whether to checkout submodules recursively.
138         (default: true)
139     :gerrit_sonar_triggers: Override Gerrit Triggers.
140
141 Tox Verify
142 ----------
143
144 Tox runner to verify a project. This job is pyenv aware so if the image
145 contains an installation of pyenv at /opt/pyenv it will pick it up and run
146 Python tests with the appropriate Python versions. This job will set the
147 following pyenv variables before running.
148
149 .. code:: bash
150
151    export PYENV_ROOT="/opt/pyenv"
152    export PATH="$PYENV_ROOT/bin:$PATH"
153
154 :Template Names:
155
156     - {project-name}-tox-verify-{stream}
157     - gerrit-tox-verify
158     - github-tox-verify
159
160 :Required Parameters:
161
162     :build-node: The node to run build on.
163     :jenkins-ssh-credential: Credential to use for SSH. (Generally set
164         in defaults.yaml)
165
166 :Optional Parameters:
167
168     :branch: The branch to build against. (default: master)
169     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
170     :build-timeout: Timeout in seconds before aborting build. (default: 10)
171     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
172     :python-version: Version of Python to configure as a base in virtualenv.
173         (default: python3)
174     :stream: Keyword representing a release code-name.
175         Often the same as the branch. (default: master)
176     :submodule-recursive: Whether to checkout submodules recursively.
177         (default: true)
178     :tox-dir: Directory containing the project's tox.ini relative to
179         the workspace. Empty works if tox.ini is at project root.
180         (default: '')
181     :tox-envs: Tox environments to run. If blank run everything described
182         in tox.ini. (default: '')