Add python tox verify job
[releng/global-jjb.git] / jjb / lf-macros.yaml
1 ---
2 # BUILDERS
3 - builder:
4     name: lf-infra-create-netrc
5     # Macro to create a ~/.netrc file from a Maven settings.xml
6     # Parameters:
7     #     {server-id} The id of a server as defined in settings.xml
8     builders:
9       - inject:
10           properties-content: 'SERVER_ID={server-id}'
11       - shell: !include-raw-escape: ../shell/create-netrc.sh
12
13 - builder:
14     name: lf-infra-gpg-verify-git-signature
15     # Verify gpg signature of the latest commit message in $WORKSPACE
16     #
17     # This command assumes that $WORKSPACE is a git repo.
18     #
19     # TODO: Verify signature after downloading users public key from a locally
20     # created repository instead of the public keymesh. This requires a process
21     # in place to get ODL developers public keys into a local repository without
22     # increasing the job thoughput.
23     builders:
24       - shell: !include-raw: ../shell/gpg-verify-git-signature.sh
25
26 - builder:
27     name: lf-infra-ship-logs
28     builders:
29       - config-file-provider:
30           files:
31             - file-id: 'jenkins-log-archives-settings'
32               variable: 'SETTINGS_FILE'
33       - lf-infra-create-netrc:
34           server-id: logs
35       - shell: !include-raw:
36           - ../shell/lftools-install.sh
37           - ../shell/logs-deploy.sh
38       - shell: !include-raw:
39           - ../shell/logs-clear-credentials.sh
40       - description-setter:
41           regexp: '^Build logs: .*'
42
43 - builder:
44     name: lf-jacoco-nojava-workaround
45     builders:
46       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
47
48 # call maven-target builder with a goal of --version to force Jenkins to
49 # install the needed maven version
50 - builder:
51     name: lf-maven-install
52     builders:
53       - maven-target:
54           maven-version: '{maven-version}'
55           goals: '--version'
56
57 # Push a global settings and user settings maven files
58 - builder:
59     name: lf-provide-maven-settings
60     builders:
61       - config-file-provider:
62           files:
63             - file-id: '{global-settings-file}'
64               variable: 'GLOBAL_SETTINGS_FILE'
65             - file-id: '{settings-file}'
66               variable: 'SETTINGS_FILE'
67
68
69 # PARAMETERS
70 # Standard parameters used in the LF CI environments. Gerrit variables are not
71 # used by GitHub projects, but defining them isn't harmful
72 - parameter:
73     name: lf-infra-parameters
74     parameters:
75       - string:
76           name: PROJECT
77           default: '{project}'
78           description: |
79               Parameter to identify a Gerrit project. This is typically the
80               project repo path as exists in Gerrit.
81               For example: ofextensions/circuitsw
82
83               (Deprecated) Please use GERRIT_PROJECT instead. A future version
84               of global-jjb will remove this variable.
85       - string:
86           name: GERRIT_PROJECT
87           default: '{project}'
88           description: |
89               Parameter to identify Gerrit project. This is typically the
90               project repo path as exists in Gerrit.
91               For example: ofextensions/circuitsw
92
93               Note that Gerrit will override this parameter automatically if a
94               job is triggered by Gerrit.
95       - string:
96           name: GERRIT_BRANCH
97           default: '{branch}'
98           description: |
99               Parameter to identify a Gerrit branch.
100
101               Note that Gerrit will override this parameter automatically if a
102               job is triggered by Gerrit.
103       - string:
104           name: GERRIT_REFSPEC
105           default: ''
106           description: |
107               Parameter to identify a refspec when pulling from Gerrit.
108
109               Note that Gerrit will override this parameter automatically if a
110               job is triggered by Gerrit.
111
112 # Useful parameters when working with TOX
113 # https://tox.readthedocs.io/
114 - parameter:
115     name: lf-infra-tox-parameters
116     parameters:
117       - string:
118           name: TOX_DIR
119           default: '{tox-dir}'
120           description: |
121               Path to directory containing tox.ini file.
122       - string:
123           name: TOX_ENVS
124           default: '{tox-envs}'
125           description: |
126               Tox environments to run build against.
127               Example: docs,py2,py3
128
129 # Set an env var for shell scripts to be able to call the dynamically installed
130 # maven without having to calculate the path themselves
131 - parameter:
132     name: lf-maven-exec
133     parameters:
134       - string:
135           name: MVN
136           # yamllint disable-line rule:line-length
137           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
138           description: 'Maven selector to be used by shell scripts'
139
140
141 # PROPERTIES
142 - property:
143     name: lf-infra-properties
144     properties:
145       - build-discarder:
146           # Allow build data to be stored at a length configured by the
147           # downstream project.
148           days-to-keep: '{build-days-to-keep}'
149           # Do not allow artifacts to be stored in Jenkins.
150           artifact-num-to-keep: 0
151
152 # PUBLISHERS
153 - publisher:
154     name: lf-infra-publish
155     # lf-infra macro to finish up a build.
156     #
157     # Handles the following:
158     #   - Shipping logs to Nexus logs site repository
159     #   - Cleanup workspace
160     publishers:
161       - postbuildscript:
162           builders:
163             - lf-infra-ship-logs
164           script-only-if-succeeded: false
165           script-only-if-failed: false
166           mark-unstable-if-failed: false
167       - workspace-cleanup:
168           exclude:
169             # Do not clean up *.jenkins-trigger files for jobs that use a
170             # properties file as input for triggering another build.
171             - '**/*.jenkins-trigger'
172           fail-build: false
173
174 # SCM
175 - scm:
176     name: lf-infra-gerrit-scm
177     scm:
178       - git:
179           credentials-id: '{jenkins-ssh-credential}'
180           url: '{git-url}'
181           refspec: '{refspec}'
182           branches:
183             - 'refs/heads/{branch}'
184           skip-tag: true
185           wipe-workspace: true
186           submodule:
187             recursive: '{submodule-recursive}'
188           choosing-strategy: '{choosing-strategy}'
189
190 - scm:
191     name: lf-infra-github-scm
192     scm:
193       - git:
194           credentials-id: '{jenkins-ssh-credential}'
195           url: '{url}'
196           refspec: '{refspec}'
197           skip-tag: true
198           wipe-workspace: true
199           submodule:
200             recursive: '{submodule-recursive}'
201           choosing-strategy: '{choosing-strategy}'
202
203 # WRAPPERS
204 - wrapper:
205     name: lf-infra-wrappers
206     wrappers:
207       - mask-passwords
208       - timeout:
209           type: absolute
210           timeout: '{build-timeout}'
211           timeout-var: 'BUILD_TIMEOUT'
212           fail: true
213       - timestamps
214       - ssh-agent-credentials:
215           users:
216             - '{jenkins-ssh-credential}'
217       - openstack:
218           single-use: true