Merge "Set wget to quiet mode to hide Maven DL output"
[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-infra-sysstat
45     builders:
46       - shell: !include-raw:
47           - ../shell/sysstat.sh
48
49 - builder:
50     name: lf-jacoco-nojava-workaround
51     builders:
52       - shell: 'mkdir -p $WORKSPACE/target/classes $WORKSPACE/jacoco/classes'
53
54 # call maven-target builder with a goal of --version to force Jenkins to
55 # install the needed maven version
56 - builder:
57     name: lf-maven-install
58     builders:
59       # Create a $HOME/.wgetrc to make the Maven download quiet.
60       - shell: 'echo "quiet=on" > "$HOME/.wgetrc"'
61       - maven-target:
62           maven-version: '{maven-version}'
63           goals: '--version'
64       - shell: 'rm "$HOME/.wgetrc"'
65
66 # Push a global settings and user settings maven files
67 - builder:
68     name: lf-provide-maven-settings
69     builders:
70       - config-file-provider:
71           files:
72             - file-id: '{global-settings-file}'
73               variable: 'GLOBAL_SETTINGS_FILE'
74             - file-id: '{settings-file}'
75               variable: 'SETTINGS_FILE'
76
77
78 # PARAMETERS
79 # Standard parameters used in the LF CI environments. Gerrit variables are not
80 # used by GitHub projects, but defining them isn't harmful
81 - parameter:
82     name: lf-infra-parameters
83     parameters:
84       - string:
85           name: PROJECT
86           default: '{project}'
87           description: |
88               Parameter to identify a Gerrit project. This is typically the
89               project repo path as exists in Gerrit.
90               For example: ofextensions/circuitsw
91
92               (Deprecated) Please use GERRIT_PROJECT instead. A future version
93               of global-jjb will remove this variable.
94       - string:
95           name: GERRIT_PROJECT
96           default: '{project}'
97           description: |
98               Parameter to identify Gerrit project. This is typically the
99               project repo path as exists in Gerrit.
100               For example: ofextensions/circuitsw
101
102               Note that Gerrit will override this parameter automatically if a
103               job is triggered by Gerrit.
104       - string:
105           name: GERRIT_BRANCH
106           default: '{branch}'
107           description: |
108               Parameter to identify a Gerrit branch.
109
110               Note that Gerrit will override this parameter automatically if a
111               job is triggered by Gerrit.
112       - string:
113           name: GERRIT_REFSPEC
114           default: ''
115           description: |
116               Parameter to identify a refspec when pulling from Gerrit.
117
118               Note that Gerrit will override this parameter automatically if a
119               job is triggered by Gerrit.
120
121 # Useful parameters when working with TOX
122 # https://tox.readthedocs.io/
123 - parameter:
124     name: lf-infra-tox-parameters
125     parameters:
126       - string:
127           name: TOX_DIR
128           default: '{tox-dir}'
129           description: |
130               Path to directory containing tox.ini file.
131       - string:
132           name: TOX_ENVS
133           default: '{tox-envs}'
134           description: |
135               Tox environments to run build against.
136               Example: docs,py2,py3
137
138 # Set an env var for shell scripts to be able to call the dynamically installed
139 # maven without having to calculate the path themselves
140 - parameter:
141     name: lf-maven-exec
142     parameters:
143       - string:
144           name: MVN
145           # yamllint disable-line rule:line-length
146           default: '/w/tools/hudson.tasks.Maven_MavenInstallation/{maven-version}/bin/mvn'
147           description: 'Maven selector to be used by shell scripts'
148
149
150 # PROPERTIES
151 - property:
152     name: lf-infra-properties
153     properties:
154       - build-discarder:
155           # Allow build data to be stored at a length configured by the
156           # downstream project.
157           days-to-keep: '{build-days-to-keep}'
158           # Do not allow artifacts to be stored in Jenkins.
159           artifact-num-to-keep: 0
160
161 # PUBLISHERS
162 - publisher:
163     name: lf-infra-publish
164     # lf-infra macro to finish up a build.
165     #
166     # Handles the following:
167     #   - Shipping logs to Nexus logs site repository
168     #   - Cleanup workspace
169     publishers:
170       - postbuildscript:
171           builders:
172             - lf-infra-sysstat
173             - lf-infra-ship-logs
174           script-only-if-succeeded: false
175           script-only-if-failed: false
176           mark-unstable-if-failed: false
177       - workspace-cleanup:
178           exclude:
179             # Do not clean up *.jenkins-trigger files for jobs that use a
180             # properties file as input for triggering another build.
181             - '**/*.jenkins-trigger'
182           fail-build: false
183
184 # SCM
185 - scm:
186     name: lf-infra-gerrit-scm
187     scm:
188       - git:
189           credentials-id: '{jenkins-ssh-credential}'
190           url: '{git-url}'
191           refspec: '{refspec}'
192           branches:
193             - 'refs/heads/{branch}'
194           skip-tag: true
195           wipe-workspace: true
196           submodule:
197             recursive: '{submodule-recursive}'
198           choosing-strategy: '{choosing-strategy}'
199
200 - scm:
201     name: lf-infra-github-scm
202     scm:
203       - git:
204           credentials-id: '{jenkins-ssh-credential}'
205           url: '{url}'
206           refspec: '{refspec}'
207           skip-tag: true
208           wipe-workspace: true
209           submodule:
210             recursive: '{submodule-recursive}'
211           choosing-strategy: '{choosing-strategy}'
212
213 # WRAPPERS
214 - wrapper:
215     name: lf-infra-wrappers
216     wrappers:
217       - mask-passwords
218       - timeout:
219           type: absolute
220           timeout: '{build-timeout}'
221           timeout-var: 'BUILD_TIMEOUT'
222           fail: true
223       - timestamps
224       - ssh-agent-credentials:
225           users:
226             - '{jenkins-ssh-credential}'
227       - openstack:
228           single-use: true