• Stars
    star
    288
  • Rank 143,818 (Top 3 %)
  • Language
    Groovy
  • Created over 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Collection of custom steps and variables for our Jenkins instance(s)

Pipeline Global Library for ci.jenkins.io

icon pipeline library

This repository contains a series of steps and variables for use inside of the Jenkins project’s own Jenkins instance(s).

Check this description of available services.

Useful steps:

buildPlugin

Applies the appropriate defaults for building a Maven-based plugin project on Linux and Windows.

You are advised to be using a 2.x or newer parent POM.

Jenkinsfile
buildPlugin(
  useContainerAgent: true,
  configurations: [
    [platform: 'linux', jdk: 11],
    [platform: 'linux', jdk: 17],
    [platform: 'windows', jdk: 11],
])

Optional arguments

  • repo (default: null inherit from Multibranch) - custom Git repository to check out

  • useContainerAgent (default: false) - uses a Container agent instead of a Virtual Machine: usually faster to start and generates less costs for the project

    • Please note that the implementation of "containers" can be changed over time

  • failFast (default: true) - instruct Maven tests to fail fast

  • platforms (default: ['linux', 'windows']) - Labels matching platforms to execute the steps against in parallel

  • jdkVersions (default: [8]) - JDK version numbers, must match a version number jdk tool installed

  • jenkinsVersions: (default: [null]) - a matrix of Jenkins baseline versions to build/test against in parallel (null means default, only available for Maven projects)

  • configurations: An alternative way to specify platforms, jdkVersions and jenkinsVersions (that can not be combined with any of them).

  • useArtifactCachingProxy: (default: true) - if set to false, artifacts will not use one of the artifact caching proxy depending on the agent provider (Azure, DigitalOcean or AWS), and will directly use repo.jenkins-ci.org instead (discouraged as less reliable and consuming bandwidth)

    • Those options will run the build for all combinations of their values. While that is desirable in many cases, configurations permit to provide a specific combinations of label and java/jenkins versions to use

      buildPlugin(/*...*/, configurations: [
        [ platform: "linux", jdk: "11", jenkins: null ],
        [ platform: "windows", jdk: "11", jenkins: null ],
        [ platform: "linux", jdk: "17", jenkins: "2.400" ]
      ])
  • tests: (default: null) - a map of parameters to run tests during the build. The test results and the JaCoCo code coverage results are recorded after the build with the corresponding Jenkins plugins.

    • skip - If true, skip all the tests by setting the -skipTests profile. It will also skip FindBugs in modern Plugin POMs.

  • jacoco: (default: null) - a map of parameters to change the default configuration of the recordCoverage step of the Code Coverage Plugin. This step is called after a plugin build to record the code coverage results of JaCoCo. See recordCoverage step documentation for a list of available configuration parameters.

  • pit: (default: null) - a map of parameters to change the default configuration of the recordCoverage step of the Code Coverage Plugin. See recordCoverage step documentation for a list of available configuration parameters. Since running PIT is a time-consuming task, PIT is disabled by default. You need to enable it by setting the property skip to false as well.

  • spotbugs, checkstyle, pmd, cpd: (default: null) - a map of parameters to archive SpotBugs, CheckStyle, PMD, or CPD warnings, respectively (only available for Maven projects). These values can replace or amend the default configuration for the recordIssues step of the Warnings NG Plugin. See Warnings NG Plugin documentation for a list of available configuration parameters.

  • timeout: (default: 60) - the number of minutes for build timeout, cannot be bigger than 180, i.e. 3 hours.

Note
The recordIssues steps of the warnings plugin and the recordCoverage steps of the coverage plugin run on the first platform/jdkVersion,jenkinsVersion combination only. So in the example below it will run for linux/jdk11 but not on jdk17.

Usage:

Jenkinsfile
buildPlugin(platforms: ['linux'],
        jdkVersions: [11, 17],
        jacoco: [sourceCodeRetention: 'MODIFIED'],
        pit: [skip: false],
        checkstyle: [qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]],
        pmd: [trendChartType: 'TOOLS_ONLY', qualityGates: [[threshold: 1, type: 'NEW', unstable: true]]])

buildPluginWithGradle()

Builds a Jenkins plugin using Gradle. The implementation follows the standard build/test/archive pattern. The method targets compatibility with Gradle JPI Plugin, and it may not work for other use-cases.

Optional arguments

  • repo (default: null inherit from Multibranch) - custom Git repository to check out

  • failFast (default: true) - instruct the build to fail fast when one of the configurations fail

  • platforms (default: ['linux', 'windows']) - Labels matching platforms to execute the steps against in parallel

  • jdkVersions (default: [8]) - JDK version numbers, must match a version number jdk tool installed

  • configurations: An alternative way to specify platforms, jdkVersions (that can not be combined with any of them)

    • Those options will run the build for all combinations of their values. While that is desirable in many cases, configurations permit to provide a specific combinations of label and java/jenkins versions to use

      buildPluginWithGradle(/*...*/, configurations: [
        [ platform: "linux", jdk: "8" ],
        [ platform: "windows", jdk: "8"],
      ])
  • tests: (default: null) - a map of parameters to run tests during the build

    • skip - If true, skip all the tests.

  • jacoco: (default: null) - a map of parameters to change the default configuration of the recordCoverage step of the Code Coverage Plugin. This step is called after a plugin build to record the code coverage results of JaCoCo. See recordCoverage step documentation for a list of available configuration parameters.

  • spotbugs, checkstyle: (default: null) - a map of parameters to archive SpotBugs or CheckStyle warnings, respectively. These values can replace or amend the default configuration for the recordIssues step of the Warnings NG Plugin. See Warnings NG Plugin documentation for a list of available configuration parameters.

  • timeout: (default: 60) - the number of minutes for build timeout, cannot be bigger than 180, i.e. 3 hours.

  • noIncrementals: (default: false) - de-activates incremental version publication.

Limitations

Not all features of buildPlugin() for Maven are supported in the gradle flow. Examples of not supported features:

  • Configuring jenkinsVersion for the build flow (as standalone arguments or as configurations)

  • Usage of Azure Container Instances as agents (only Maven agents are configured)

infra.isTrusted()

Determine whether the Pipeline is executing in an internal "trusted" Jenkins environment

Jenkinsfile
if (infra.isTrusted()) {
    /* perform some trusted action like a deployment */
}

infra.ensureInNode(nodeLabels, body)

Ensures that the given code block is runs in a node with the specified labels

Jenkinsfile
infra.ensureInNode('docker,java') {
    sh 'docker -v'
}

runBenchmarks

Runs JMH benchmarks and archives benchmark reports on highmem nodes.

Supported parameters:

artifacts

(Optional) If artifacts is not null, invokes archiveArtifacts with the given string value.

Example

runBenchmarks('jmh-report.json')

buildDockerAndPublishImage(imageName, config)

Lints, Builds, then publishes a docker image.

Adds a bunch of build args you can use in your docker image:

  • GIT_COMMIT_REV - The commit that triggered this build

  • GIT_SCM_URL - Url to repo

  • BUILD_DATE - Date that the image was built (now)

Supported parameters:

imageName

Name of the docker image to build

configs

(Optional) extra flags

registry: override the smart default of jenkinsciinfra/ or jenkins4eval/ dockerfile: override the default dockerfile of Dockerfile

Example

buildDockerImage_k8s('plugins-site-api')

Contribute

Requirements

  • (Open)JDK v8

  • Maven 3.6.x

===

More Repositories

1

jenkins.io

A static site for the Jenkins automation server
HTML
315
star
2

update-center2

Jenkins Update Center backend
Java
121
star
3

jenkins-infra

Jenkins main control repo for R10k and our Puppet Enterprise managed infrastructure
Ruby
108
star
4

evergreen

An automatically self-updating Jenkins distribution
JavaScript
95
star
5

repository-permissions-updater

Artifactory permissions synchronization tool and data set
Java
79
star
6

kubernetes-management

Jenkins Infrastructure Kubernetes Management
Shell
55
star
7

cn.jenkins.io

Chinese version of the website
HTML
34
star
8

azure

Documentation, tooling and other resources related to the Azure account used by the Jenkins project
HCL
27
star
9

crawler

tools crawler
Groovy
26
star
10

plugin-health-scoring

This project aims to introduce a metric system to calculate the health score of each plugin within the Jenkins ecosystem and reflect the final scores on the Plugin Site for the plugin maintainers and users.
Java
24
star
11

ircbot

Jenkins IRCbot
Java
23
star
12

documentation

Documentation for users of Jenkins project infrastructure
22
star
13

plugin-site

This is the frontend application driven by data from the Jenkins Plugin Site API.
JavaScript
20
star
14

wechat

WeChat for Jenkins (Jenkins 官方微信公众号)
Groovy
19
star
15

packer-images

This repository hosts the packer definitions for the Jenkins Infrastructure
Shell
17
star
16

helpdesk

Open your Infrastructure related issues here for the Jenkins project
Shell
16
star
17

pipeline-steps-doc-generator

Pipeline step documentation generator
Java
15
star
18

release

Contains every things needed to release jenkins core from the jenkins infra project
Shell
13
star
19

docker-openvpn

This project contents everything needed to build an openvpn docker image used by the Jenkins Infrastructure Project
Shell
10
star
20

jenkins-codeql

Custom CodeQL code scanning rules for Jenkins
Java
10
star
21

mock-ldap

Mock LDAP container useful for testing.
Dockerfile
9
star
22

plugins-wiki-docs

JavaScript
9
star
23

jira

Docker container to run JIRA
Shell
7
star
24

helm-charts

Helm chart repository containing the jenkins-infra public charts.
Mustache
7
star
25

account-app

Jenkins Account Management/Sign-up App
Java
7
star
26

iep

Infrastructure Enhancement Proposals
7
star
27

aws

Documentation, tooling and other resources related to the Jenkins Infrastructure Project parts hosted in Amazon Web Services (AWS).
HCL
7
star
28

community-functions

Azure Functions to implement community automation for the Jenkins project
JavaScript
6
star
29

datadog

Jenkins OSS infrastructure monitoring stuff
HCL
6
star
30

status

Jenkins Infrastructure Status page https://status.jenkins.io
HTML
6
star
31

docker-jenkins-lts

a docker image containing the latest jenkins lts release and plugins
Shell
6
star
32

confluence

Containerized Confluence that runs wiki.jenkins-ci.org
Shell
6
star
33

backend-extension-indexer

Generate the list of extension points and their known implementations
Java
6
star
34

uc

Go
5
star
35

backend-jenkins-plugin-info-plugin

Jenkins backend: jenkins-plugin-info-plugin
Java
5
star
36

jenkins-io-components

TypeScript
4
star
37

awestruct-ibeams

Archived as it has been inlined in jenkins.io (see https://github.com/jenkins-infra/jenkins.io/pull/6291). Collection of Awestruct extensions to make building sites more structurally sound.
Ruby
4
star
38

asciidoctor-jenkins-extensions

Extensions to asciidoctor syntax for Jenkins-related materials
Ruby
4
star
39

docker-builder

A Docker image providing tools for... building Docker Images (usually in rootless or daemon-less contexts)
Dockerfile
3
star
40

docker-jenkins-weeklyci

a docker image containing the latest jenkins weekly release and plugins
Shell
3
star
41

stories

A static site for the Jenkins is the way
JavaScript
3
star
42

.github

Global configurations for the Jenkins Infrastructure organization on GitHub
3
star
43

acceptance-tests

Infrastructure acceptance testing.
3
star
44

java.net-scm-issue-link

java.net issue update daemon
Java
3
star
45

docker-ldap

OpenLDAP server that runs accounts
Shell
3
star
46

stats.jenkins.io

Revamped Jenkins Infra Stats Website as a part of GSoC 2024
HTML
3
star
47

docker-mirrorbits

This repository hold everything need to mirrorbits based on https://github.com/etix/mirrorbits/
Dockerfile
2
star
48

docker-terraform

A Docker Image to provide a working environment around terraform
Dockerfile
2
star
49

infra-reports

Generate reports based on GitHub and Artifactory data (formerly github-reports)
JavaScript
2
star
50

bind

Docker container that runs DNS server
Dockerfile
2
star
51

javadoc

Groovy
2
star
52

docker-confluence-data

confluence-data is a repository containing confluence data exported to html
HTML
2
star
53

backend-commit-history-parser

Shell
2
star
54

azure-net

Network resources related to the Azure account used by the Jenkins project
HCL
2
star
55

captain-hook

Go
2
star
56

jenkins-wiki-exporter

Quick util to convert jenkins plugin wiki format to github markdown or asciidoc
JavaScript
2
star
57

docker-crond

Simple docker image running crond
Dockerfile
2
star
58

docker-packaging

This repository contains everything needed to build a docker image used to package jenkins core
Dockerfile
2
star
59

docs.jenkins.io

Versioned docs of jenkins.io
CSS
2
star
60

jenkins-usage-stats

Jenkins usage statistics reports generator
Go
1
star
61

digitalocean

Documentation, tooling and other resources related to the Jenkins Infrastructure Project parts hosted in Digital Ocean.
HCL
1
star
62

Enhancing-LLM-with-Jenkins-Knowledge

🚀 this project aims to develop an app using an existing open-source LLM with data collected for domain-specific Jenkins knowledge that can be fine-tuned locally and set up with a proper UI for the user to interact with.
Jupyter Notebook
1
star
63

github-reusable-workflows

Repository for reusable workflows
1
star
64

confluence-cache

Container that runs the pre-generated cache in front of Confluence
Ruby
1
star
65

usage-log-decrypter

Decrypts & produces anonymized summary of usage info
Java
1
star
66

pipeline-metadata-utils

Pipeline step metadata utility classes
Java
1
star
67

patron

Patron of Jenkins program
Groovy
1
star
68

interesting-category-action

Validate that the next draft release is interesting
Shell
1
star
69

docker-keycloak-theme

JavaScript
1
star
70

docker-hashicorp-tools

Dockerfile
1
star
71

infra-mirror

mirror script
Shell
1
star
72

rating

Community rating of releases
PHP
1
star
73

docker-helmfile

Docker Image used to execute Helmfile commands, with all the expected tooling
Dockerfile
1
star
74

jira-ldap-syncer

LDAP to JIRA bridge
Java
1
star
75

backend-confluence-spam-remover

Jenkins backend: confluence-spam-remover
Mathematica
1
star
76

jenkins-maven-cd-action

Shell
1
star
77

backend-release.rss

Generate release history RSS feed
Groovy
1
star
78

shared-tools

This repository hosts the shared tools (between local development and CI libraries) of the Jenkins infrastructure: Makefiles, CLIs, etc.
HCL
1
star
79

l10n-server

Jenkins backend: l10n-server
Java
1
star
80

merge-all-repo

This script merges all the Jenkins repositories into one repository
Groovy
1
star
81

jenkins-security-scan

GitHub Workflow and Action for the Jenkins Security Scan
1
star
82

homebrew-tap

Ruby
1
star
83

jenkins-contribution-stats

Shell
1
star
84

contributor-spotlight

Jenkins Contributor Spotlight feature
JavaScript
1
star