Add macro for github SCM and bits for ghrpb
[releng/global-jjb.git] / jjb / lf-macros.yaml
1 ---
2 - builder:
3     name: create-netrc
4     # Macro to create a ~/.netrc file from a Maven settings.xml
5     # Parameters:
6     #     {server-id} The id of a server as defined in settings.xml
7     builders:
8       - inject:
9           properties-content: 'SERVER_ID={server-id}'
10       - shell: !include-raw-escape: ../shell/create-netrc.sh
11
12 - builder:
13     name: gpg-verify-git-signature
14     # Verify gpg signature of the latest commit message in $WORKSPACE
15     #
16     # This command assumes that $WORKSPACE is a git repo.
17     #
18     # TODO: Verify signature after downloading users public key from a locally
19     # created repository instead of the public keymesh. This requires a process
20     # in place to get ODL developers public keys into a local repository without
21     # increasing the job thoughput.
22     builders:
23       - shell: !include-raw: ../shell/gpg-verify-git-signature.sh
24
25 - builder:
26     name: lf-infra-ship-logs
27     builders:
28       - config-file-provider:
29           files:
30             - file-id: 'jenkins-log-archives-settings'
31               variable: 'SETTINGS_FILE'
32       - create-netrc:
33           server-id: logs
34       - shell: !include-raw:
35           - ../shell/lftools-install.sh
36           - ../shell/logs-deploy.sh
37       - shell: !include-raw:
38           - ../shell/logs-clear-credentials.sh
39       - description-setter:
40           regexp: '^Build logs: .*'
41
42 - parameter:
43     name: lf-infra-parameters
44     parameters:
45       - string:
46           name: PROJECT
47           default: '{project}'
48           description: |
49               Parameter to identify a Gerrit project. This is typically the
50               project repo path as exists in Gerrit.
51               For example: ofextensions/circuitsw
52
53               (Deprecated) Please use GERRIT_PROJECT instead. A future version
54               of global-jjb will remove this variable.
55       - string:
56           name: GERRIT_PROJECT
57           default: '{project}'
58           description: |
59               Parameter to identify Gerrit project. This is typically the
60               project repo path as exists in Gerrit.
61               For example: ofextensions/circuitsw
62
63               Note that Gerrit will override this parameter automatically if a
64               job is triggered by Gerrit.
65       - string:
66           name: GERRIT_BRANCH
67           default: '{branch}'
68           description: |
69               Parameter to identify a Gerrit branch.
70
71               Note that Gerrit will override this parameter automatically if a
72               job is triggered by Gerrit.
73       - string:
74           name: GERRIT_REFSPEC
75           default: ''
76           description: |
77               Parameter to identify a refspec when pulling from Gerrit.
78
79               Note that Gerrit will override this parameter automatically if a
80               job is triggered by Gerrit.
81
82 - property:
83     name: lf-infra-properties
84     properties:
85       - build-discarder:
86           # Allow build data to be stored at a length configured by the
87           # downstream project.
88           days-to-keep: '{build-days-to-keep}'
89           # Do not allow artifacts to be stored in Jenkins.
90           artifact-num-to-keep: 0
91
92 - publisher:
93     name: lf-infra-publish
94     # lf-infra macro to finish up a build.
95     #
96     # Handles the following:
97     #   - Shipping logs to Nexus logs site repository
98     #   - Cleanup workspace
99     publishers:
100       - postbuildscript:
101           builders:
102             - lf-infra-ship-logs
103           script-only-if-succeeded: false
104           script-only-if-failed: false
105           mark-unstable-if-failed: false
106       - workspace-cleanup:
107           exclude:
108             # Do not clean up *.jenkins-trigger files for jobs that use a
109             # properties file as input for triggering another build.
110             - '**/*.jenkins-trigger'
111           fail-build: false
112
113 - scm:
114     name: lf-infra-gerrit-scm
115     scm:
116       - git:
117           credentials-id: '{jenkins-ssh-credential}'
118           url: '$GIT_URL/$GERRIT_PROJECT'
119           refspec: '{refspec}'
120           branches:
121             - 'refs/heads/{branch}'
122           skip-tag: true
123           wipe-workspace: true
124           submodule:
125             recursive: '{submodule-recursive}'
126           choosing-strategy: '{choosing-strategy}'
127
128 - scm:
129     name: lf-infra-github-scm
130     scm:
131       - git:
132           credentials-id: '{jenkins-ssh-credential}'
133           url: '$GIT_URL/$PROJECT'
134           refspec: '{refspec}'
135           skip-tag: true
136           wipe-workspace: true
137           submodule:
138             recursive: '{submodule-recursive}'
139           choosing-strategy: '{choosing-strategy}'
140
141 - wrapper:
142     name: lf-infra-wrappers
143     wrappers:
144       - mask-passwords
145       - timeout:
146           type: absolute
147           timeout: '{build-timeout}'
148           timeout-var: 'BUILD_TIMEOUT'
149           fail: true
150       - timestamps
151       - ssh-agent-credentials:
152           users:
153             - '{jenkins-ssh-credential}'
154       - openstack:
155           single-use: true