Add pre-build scripts to Python templates
[releng/global-jjb.git] / docs / jjb / lf-release-jobs.rst
1 .. _lf-global-jjb-release:
2
3 #######################
4 Self Serve Release Jobs
5 #######################
6
7 Self serve release jobs allow a project to create a releases directory and then place a release file in it.
8 Jenkins will pick this up and then promote the artifact from the staging log directory (log_dir) and tag the release
9 with the defined version. maven_central_url is optional
10
11 .. note::
12
13    Example of a maven release file:
14
15 .. code-block:: bash
16
17    $ cat releases/maven-1.0.0.yaml
18    ---
19    distribution_type: 'maven'
20    version: '1.0.0'
21    project: 'example-project'
22    log_dir: 'example-project-maven-stage-master/17/'
23
24
25    Example of a container release file:
26
27 .. code-block:: bash
28
29    $ cat releases/container-1.0.0.yaml
30    ---
31    distribution_type: 'container'
32    version: '1.0.0'
33    project: 'example-project'
34    log_dir: 'example-project-maven-docker-stage-master/17/'
35
36
37 .. note::
38
39    Job should be appended under gerrit-maven-stage
40    Example of a terse Jenkins job to call global-jjb macro:
41
42 .. code-block:: none
43
44     - gerrit-maven-stage:
45         sign-artifacts: true
46         build-node: centos7-docker-8c-8g
47         maven-versions-plugin: true
48     - '{project-name}-gerrit-release-jobs':
49         build-node: centos7-docker-8c-8g
50
51 .. note::
52
53    Release Engineers Please follow the setup guide before adding the job definition:
54
55
56 Setup for LFID Nexus Jenkins and Gerrit:
57 ========================================
58
59 LFID
60 ====
61
62 Create an ``lfid`` and an ``ssh-key``
63
64 ``YOUR_RELEASE_USERNAME`` for example: onap-release
65 ``YOUR_RELEASE_EMAIL`` for example: collab-it+onap-release@linuxfoundation.org
66
67 ssh-key example:
68
69 .. code-block:: bash
70
71    ssh-keygen -t rsa -C "collab-it+odl-release@linuxfoundation.org"  -f /tmp/odl-release
72
73
74 `Create an LFID with the above values <https://identity.linuxfoundation.org>`_
75
76
77 Nexus
78 =====
79
80 Create a Nexus account called ``'jenkins-release'`` with promote privileges.
81
82 .. image:: ../_static/nexus-promote-privs.png
83
84 Gerrit
85 ======
86
87 Log into your Gerrit with ``YOU_RELEASE_USERNAME``, upload the publick part of the ``ssh-key`` you created earlier.
88 Log out of Gerrit and log in again with your normal account for the next steps.
89
90
91 In Gerrit create a new group called ``self-serve-release`` and give it direct push rights via ``All-Projects``
92 Add ``YOUR_RELEASE_USERNAME`` to group ``self-serve-release`` and group ``Non-Interactive Users``
93
94
95 In All project, grant group self-serve-release the following:
96
97 .. code-block:: none
98
99     [access "refs/heads/*"]
100       push = group self-serve-release
101     [access "refs/tags/*"]
102       createTag = group self-serve-release
103       createSignedTag = group self-serve-release
104       forgeCommitter = group self-serve-release
105       push = group self-serve-release
106
107
108 Jenkins
109 =======
110
111 Add a global credential to Jenkins called ``jenkins-release`` and set the ID: ``'jenkins-release'``
112 as its value insert the private portion of the ``ssh-key`` that you created for your Gerrit user.
113
114 Add Global vars in Jenkins:
115 Jenkins configure -> Global properties -> Environment variables
116
117 ``RELEASE_USERNAME = YOUR_RELEASE_USERNAME``
118 ``RELEASE_EMAIL = YOUR_RELEASE_EMAIL``
119
120 Jenkins configure -> Managed Files -> Add a New Config -> Custom File
121
122 id: signing-pubkey
123 Name: SIGNING_PUBKEY (optional)
124 Comment: SIGNING_PUBKEY (optional)
125
126 Content: (Ask Andy for the public signing key)
127 -----BEGIN PGP PUBLIC KEY BLOCK-----
128
129
130 Add or edit the managed file in Jenkins called ``lftoolsini``, appending a nexus section:
131 Jenkins Settings -> Managed files -> Add (or edit) -> Custom file
132
133 .. code-block:: none
134
135    [nexus.example.com]
136    username=jenkins-release
137    password=<plaintext password>
138
139 Ci-management
140 =============
141
142 Upgrade your projects global-jjb if needed
143 add this to your global defaults file (eg: jjb/defaults.yaml).
144
145 .. code-block:: bash
146
147    jenkins-ssh-release-credential: 'jenkins-release'
148
149 Macros
150 ======
151
152 lf-release
153 ----------
154
155 Release verify and merge jobs are the same except for their scm, trigger, and
156 builders definition. This anchor is the common template.
157
158 Job Templates
159 =============
160
161 Release Merge
162 -------------
163
164 Runs:
165
166 - sigul-install
167 - sigul-configuration
168 - checkout ref from taglist.log
169 - applies the $PROJECT.bundle
170 - signs, tags and pushes
171
172 .. code-block:: bash
173
174    lftools nexus release --server $NEXUS_URL $STAGING_REPO
175
176
177 :Template Name:
178     - {project-name}-release-merge-{stream}
179
180 :Comment Trigger: remerge
181
182 :Required parameters:
183
184     :build-node: The node to run build on.
185     :jenkins-ssh-release-credential: Credential to use for SSH. (Generally set
186         in defaults.yaml)
187     :stream: run this job against: **
188
189 :Optional parameters:
190
191     :branch: Git branch to fetch for the build. (default: all)
192     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
193     :build-timeout: Timeout in minutes before aborting build. (default: 15)
194     :project-pattern: Project to trigger build against. (default: \*\*)
195
196     :gerrit_merge_triggers: Override Gerrit Triggers.
197     :gerrit_trigger_file_paths: Override file paths filter which checks which
198         file modifications will trigger a build.
199         **default**::
200
201             - compare-type: ANT
202               pattern: 'releases/*.yaml'
203
204
205 Release Verify
206 ------------------
207
208 Release verify job checks the schema and ensures that the staging-repo.txt.gz
209 is available on the job.
210
211 - sigul-install
212 - sigul-configuration
213 - checkout ref from taglist.log
214 - applies the $PROJECT.bundle
215 - signs and shows signature
216
217
218 :Template Names:
219     - {project-name}-release-verify-{stream}
220
221 :Comment Trigger: recheck|reverify
222
223 :Required Parameters:
224
225     :build-node: The node to run build on.
226     :jenkins-ssh-credential: Credential to use for SSH. (Generally set
227         in defaults.yaml)
228     :stream: run this job against: **
229
230 :Optional Parameters:
231
232     :branch: Git branch to fetch for the build. (default: all)
233     :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
234     :build-node: The node to run build on.
235     :build-timeout: Timeout in minutes before aborting build. (default: 15)
236     :doc-dir: Directory where tox will place built docs.
237         as defined in the tox.ini (default: docs/_build/html)
238     :gerrit-skip-vote: Skip voting for this job. (default: false)
239     :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
240     :project-pattern: Project to trigger build against. (default: \*\*)
241
242     :gerrit_verify_triggers: Override Gerrit Triggers.
243     :gerrit_trigger_file_paths: Override file paths filter which checks which
244         file modifications will trigger a build.
245         **default**::
246
247             - compare-type: ANT
248               pattern: 'releases/*.yaml'