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