1 .. _lf-global-jjb-release:
3 #######################
4 Self-Serve Release Jobs
5 #######################
7 Self-serve release jobs allow a project team to direct Jenkins to
8 promote a jar file or container image from a staging area to a release
9 area. To trigger the action, create a releases/ or .releases/
10 directory, add a release yaml file to it, and submit a change set with
11 exactly one release yaml file to Gerrit. Upon merge of the change,
12 Jenkins will sign the reference extrapolated by log_dir and promote
13 the artifact. The expected format of the release yaml file is shown in
16 The build node for maven and container release jobs must be CentOS,
17 which supports the sigul client for accessing a signing server. The
18 build node for container release jobs must have Docker installed.
20 A release job can also be triggered from Jenkins via the "Build with
21 parameters" action, removing the need for a release yaml file. The
22 parameters must be filled out in the same way as a release yaml file,
23 except for the special USE_RELEASE_FILE and DRY_RUN check boxes. The
24 USE_RELEASE_FILE check box must be unchecked if the job is expected to
25 run with a release file, while passing the required information as
26 build parameters. Similarly, the DRY_RUN check box must be unchecked
27 if the job needs to be tested while skipping repository promotion to
30 The special parameters are as follows::
32 GERRIT_BRANCH = master
34 LOG_DIR = example-project-maven-stage-master/17/
35 DISTRIBUTION_TYPE = maven
36 USE_RELEASE_FILE = false
41 The release file regex is: (releases\/.*\.yaml|\.releases\/.*\.yaml).
42 In words, the directory name can be ".releases" or "releases"; the file
43 name can be anything with suffix ".yaml".
45 Example of a maven release file:
49 $ cat releases/1.0.0-maven.yaml
51 distribution_type: 'maven'
53 project: 'example-project'
54 log_dir: 'example-project-maven-stage-master/17/'
57 An example of a container release file appears below. The first
58 version string is applied to all released containers. The
59 per-container version strings are used to pull images from the
64 $ cat releases/1.0.0-container.yaml
66 distribution_type: 'container'
71 version: 1.0.0-20190806T184921Z
73 version: 1.0.0-20190806T184921Z
78 Job should be appended under gerrit-maven-stage
80 Example of a terse Jenkins job to call the global-jjb macro:
86 build-node: centos7-docker-8c-8g
87 maven-versions-plugin: true
88 - '{project-name}-gerrit-release-jobs':
89 build-node: centos7-docker-8c-8g
93 Release Engineers: please follow the setup guide below before adding the job definition.
96 Setup for LFID, Nexus, Jenkins and Gerrit
97 =========================================
102 Create an ``lfid`` and an ``ssh-key``
104 ``YOUR_RELEASE_USERNAME`` for example: onap-release
106 ``YOUR_RELEASE_EMAIL`` for example: collab-it+onap-release@linuxfoundation.org
112 ssh-keygen -t rsa -C "collab-it+odl-release@linuxfoundation.org" -f /tmp/odl-release
115 `Create an LFID with the above values <https://identity.linuxfoundation.org>`_
121 Create a Nexus account called ``'jenkins-release'`` with promote privileges.
123 .. image:: ../_static/nexus-promote-privs.png
128 Log into your Gerrit with ``YOUR_RELEASE_USERNAME``, upload the public
129 part of the ``ssh-key`` you created earlier. Log out of Gerrit and log
130 in again with your normal account for the next steps.
133 In Gerrit create a new group called ``self-serve-release`` and give it
134 direct push rights via ``All-Projects`` Add ``YOUR_RELEASE_USERNAME``
135 to group ``self-serve-release`` and group ``Non-Interactive Users``
138 In All project, grant group self-serve-release the following:
142 [access "refs/heads/*"]
143 push = group self-serve-release
144 [access "refs/tags/*"]
145 createTag = group self-serve-release
146 createSignedTag = group self-serve-release
147 forgeCommitter = group self-serve-release
148 push = group self-serve-release
154 Add a global credential to Jenkins called ``jenkins-release`` and set
155 the ID: ``'jenkins-release'`` as its value insert the private half of
156 the ``ssh-key`` that you created for your Gerrit user.
158 Add Global vars in Jenkins:
159 Jenkins configure -> Global properties -> Environment variables
161 ``RELEASE_USERNAME = YOUR_RELEASE_USERNAME``
162 ``RELEASE_EMAIL = YOUR_RELEASE_EMAIL``
164 Jenkins configure -> Managed Files -> Add a New Config -> Custom File
167 Name: SIGNING_PUBKEY (optional)
168 Comment: SIGNING_PUBKEY (optional)
170 Content: (Ask Andy for the public signing key)
171 -----BEGIN PGP PUBLIC KEY BLOCK-----
174 Add or edit the managed file in Jenkins called ``lftoolsini``,
175 appending a nexus section: Jenkins Settings -> Managed files -> Add
176 (or edit) -> Custom file
181 username=jenkins-release
182 password=<plaintext password>
187 Upgrade your project's global-jjb if needed, then add the following to
188 your global defaults file (e.g., jjb/defaults.yaml).
192 jenkins-ssh-release-credential: 'jenkins-release'
200 Release verify and merge jobs are the same except for their scm,
201 trigger, and builders definition. This anchor is the common template.
209 :Template Name: {project-name}-release-merge
211 :Comment Trigger: remerge
213 :Required parameters:
215 :build-node: The node to run build on.
216 :jenkins-ssh-release-credential: Credential to use for SSH. (Generally set
218 :stream: run this job against: **
220 :Optional parameters:
222 :branch: Git branch to fetch for the build. (default: all)
223 :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
224 :build-timeout: Timeout in minutes before aborting build. (default: 15)
225 :project-pattern: Project to trigger build against. (default: \*\*)
227 :gerrit_merge_triggers: Override Gerrit Triggers.
228 :gerrit_trigger_file_paths: Override file paths filter which checks which
229 file modifications will trigger a build.
232 - compare-type: REG_EXP
233 pattern: '(releases\/.*\.yaml|\.releases\/.*\.yaml)'
239 :Template Name: {project-name}-release-verify
241 :Comment Trigger: recheck|reverify
243 :Required Parameters:
245 :build-node: The node to run build on.
246 :jenkins-ssh-credential: Credential to use for SSH. (Generally set
248 :stream: run this job against: **
250 :Optional Parameters:
252 :branch: Git branch to fetch for the build. (default: all)
253 :build-days-to-keep: Days to keep build logs in Jenkins. (default: 7)
254 :build-node: The node to run build on.
255 :build-timeout: Timeout in minutes before aborting build. (default: 15)
256 :doc-dir: Directory where tox will place built docs.
257 as defined in the tox.ini (default: docs/_build/html)
258 :gerrit-skip-vote: Skip voting for this job. (default: false)
259 :git-url: URL clone project from. (default: $GIT_URL/$PROJECT)
260 :project-pattern: Project to trigger build against. (default: \*\*)
262 :gerrit_verify_triggers: Override Gerrit Triggers.
263 :gerrit_trigger_file_paths: Override file paths filter which checks which
264 file modifications will trigger a build.
267 - compare-type: REG_EXP
268 pattern: '(releases\/.*\.yaml|\.releases\/.*\.yaml)'