项目作者: 95jonpet

项目描述 :
CI/CD shared library for Jenkins.
高级语言: Groovy
项目地址: git://github.com/95jonpet/peterjonsson-ci.git
创建时间: 2020-03-20T21:24:51Z
项目社区:https://github.com/95jonpet/peterjonsson-ci

开源协议:

下载


peterjonsson-ci

Build Status

This is a small Jenkins shared library for CI/CD.

Author: Peter Jonsson


Usage

Important: The initPipeline() step should always be used before any other steps from this shared library.

initPipeline

Initializes the shared library. This step should always be called first.

Parameter Default Value Description
mainBranch master Main branch representing production.

This step will call initMavenPipeline() if there is a pom.xml file in the root directory of the current workspace.

  1. initPipeline()
  2. initPipeline([mainBranch: 'prod'])

Maven

initMavenPipeline

Sets the following environment (env) variables for later use with Maven:

Environment Variable Maven Property Description
PJCI_MAVEN_REVISION revision Current revision (i.e. 1.0.0) as read from the pom.xml file.
PJCI_MAVEN_CHANGELIST changelist -SNAPSHOT when not on main branch, otherwise empty.
PJCI_MAVEN_SHA1 sha1 Unique build identifier (i.e. -BRANCH_NAME.BUILD_NUMBER).
PJCI_MAVEN_VERSION version Interpolated Maven version (i.e. 1.0.0-featureX.7-SNAPSHOT).

This step should typically not be called manually.

runMaven

Run Maven. This requires mvn to be present on the current agent.

Parameter Default Value Description
phases clean verify Space separated list of Maven phases to run.

Example usage:

  1. runMaven()
  2. runMaven([phases: 'clean test'])

RPM Steps

generateRpmbuildPatch

Generates a source code patch, that rpmbuild can use, from a modified file and its original version.

Parameter Description
original Path relative to the rpmbuild topdir for the unaltered file.
modified Path relative to the rpmbuild topdir for the modified file.
output Path relative to the rpmbuild topdir for where the patch should be placed.

Example usage with the rpmbuild step:

  1. rpmbuild(version: '1.0.0', release: '1', topdir: 'src/rpm', specfile: 'hello-world.spec') {
  2. generateRpmbuildPatch([
  3. original: 'SOURCES/logback.orig.xml', // Relative to src/rpm.
  4. modified: 'SOURCES/logback.xml', // Relative to src/rpm.
  5. output: 'SOURCES/logback.patch' // Relative to src/rpm.
  6. ])
  7. }

rpmbuild

Build an RPM package from a .spec file. This requires rpmbuild to be present on the current agent.

Parameter Required Description
version Yes RPM version (i.e. 1.0.0).
release Yes RPM release (i.e. 1).
topdir Yes Rpmbuild top directory (it contains the SPECS folder).
specfile Yes Name of the .spec file to build from the topdir/SPECS folder.
Closure No Optional closure to execute before building the RPM.
  1. rpmbuild(version: '0.1', release: '8', topdir: 'src/rpm', specfile: 'my-rpm.spec')
  2. rpmbuild(version: '1.0.0', release: '1', topdir: 'src/rpm', specfile: 'hello-world.spec') {
  3. echo "Called after preparing rpmbuild but before execution."
  4. }