• Stars
    star
    187
  • Rank 199,046 (Top 5 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated about 2 months ago

Reviews

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

Repository Details

Unit-test Jenkins pipeline code with Spock

Jenkins Pipeline Support for Spock

Utility classes to help with testing Jenkins pipeline scripts and functions written in Groovy.

User Guide (GroovyDoc)

Add this library to pom.xml in the test scope:

<dependency>
	<groupId>com.homeaway.devtools.jenkins</groupId>
	<artifactId>jenkins-spock</artifactId>
	<scope>test</scope>
</dependency>

Check the CHANGELOG.md to find details about the available versions.

Working Examples

The examples directory contains working sample projects that show off the major kinds of project this library can be used with. Check them out and try building them yourself!

Specifications

This library provides a JenkinsPipelineSpecification class that extends the Spock testing framework's Specification class. To test Jenkins pipeline Groovy code, extend JenkinsPipelineSpecification instead of Specification. Please see the GroovyDoc for JenkinsPipelineSpecification for specific usage information and the Spock Framework Documentation for general usage information.

During the tests of a JenkinsPipelineSpecification suite,

  1. All Jenkins pipeline steps (@StepDescriptors) will be globally callable, e.g. you can just write sh( "echo hello" ) anywhere.
    1. "Body" closure blocks passed to any mock pipeline steps will be executed.
  2. All Jenkins pipeline variables (@Symbols and GlobalVariables) will be globally accessible, e.g. you can just write docker.inside(...) anywhere
  3. All Pipeline Shared Library Global Variables (from the /vars directory) will be globally accessible, so you can just use them anywhere.
  4. All interactions with any of those pipeline extension points will be captured by Spock mock objects.
  5. You can load any Groovy script (Jenkinsfile or Shared Library variable) to unit-test it in isolation.
  6. The Jenkins singleton instance will exist as a Spock mock object.
  7. The CpsScript execution will exist as a Spock spy object (you should never need to interact with this, but it's there).

Dependencies

There are some dependencies of this library that are marked with Maven's provided scope. This means that Maven will pull them in for building and testing this library, but when you use this library you must pull those libraries in as dependencies yourself.

This is done because these dependencies - things like the Jenkins Pipeline API, JUnit, etc - are things that

  1. You absolutely have to have as dependencies in your project in order for this library to be of any use
  2. Should not have their version or final scope controlled by this library

The dependencies that should already be in your project in order for using this library to make any sense are:

<dependency>
	<groupId>org.jenkins-ci.main</groupId>
	<artifactId>jenkins-core</artifactId>
	<version>${jenkins.version}</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>org.jenkins-ci.plugins.workflow</groupId>
	<artifactId>workflow-step-api</artifactId>
	<version>${jenkins.workflow.step.version}</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>org.jenkins-ci.plugins.workflow</groupId>
	<artifactId>workflow-cps</artifactId>
	<version>${jenkins.workflow.cps.version}</version>
	<scope>test</scope>
</dependency>
<dependency>
	<groupId>org.jenkins-ci</groupId>
	<artifactId>symbol-annotation</artifactId>
	<version>${jenkins.symbol.version}</version>
	<scope>test</scope>
</dependency>

<dependency>
	<groupId>junit</groupId>
	<artifactId>junit</artifactId>
	<version>${junit.version}</version>
	<scope>test</scope>
</dependency>

<dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>javax.servlet-api</artifactId>
	<version>${jenkins.servlet.version}</version>
	<scope>test</scope>
</dependency>

Depending on your parent pom, some of the ${jenkins.version} properties may already be defined. Be sure you define any that are not.

If your code actually writes code against classes in any of these dependencies, remove the <scope>test</scope> entry for the corresponding block(s).

Developer Guide

Building

The build of jenkins-spock is built with Maven. Normal Maven lifecycle phases apply. As long as you have a contemporary (1.8+) JDK and Maven (3.3+), it should build fine.

Testing

Unit tests of jenkins-spock will happen automatically during the test phase of the Maven build.

There is an it Maven Profile that can be activated to run integration tests:

mvn verify -Pit

The integration tests will run mvn verify on some of the Working Example Projects, using the current jenkins-spock code.

Releasing

jenkins-spock should be released by the maven-release-plugin:

mvn clean release:prepare release:perform

In order for this to succeed, the user running this must

  1. Configure GitHub credentials with push access to this repository.
  2. Configure Sonatype Nexus credentials with deploy access to the com.homeaway groupId.
  3. Configure a PGP identity so that the maven-gpg-plugin can sign artifacts.
    1. Locally, run GPG 2.1 or newer
    2. Set the default signing key to the key you want to use
    3. Provide -Dgpg.passphrase on the command-line or run interactively to be able to enter a passphrase

More Repositories

1

graphql-kotlin

Libraries for running GraphQL in Kotlin
Kotlin
1,710
star
2

cyclotron

A web platform for constructing dashboards.
CoffeeScript
1,560
star
3

waggle-dance

Hive federation service. Enables disparate tables to be concurrently accessed across multiple Hive deployments.
Java
258
star
4

styx

Programmable, asynchronous, event-based reverse proxy for JVM.
Java
249
star
5

adaptive-alerting

Anomaly detection for streaming time series, featuring automated model selection.
Java
200
star
6

bull

BULL - Bean Utils Light Library
Java
182
star
7

c3vis

Visualize the resource utilisation of Amazon ECS clusters
JavaScript
163
star
8

jarviz

Jarviz is dependency analysis and visualization tool designed for Java applications
Java
119
star
9

stream-registry

Stream Discovery and Stream Orchestration
Java
117
star
10

flyte

Flyte binds together the tools you use into easily defined, automated workflows
Go
88
star
11

circus-train

Circus Train is a dataset replication tool that copies Hive tables between clusters and clouds.
Java
87
star
12

kubernetes-sidecar-injector

Kuberbetes mutating webhook that injects a sidecar container to a pod
Go
74
star
13

mittens

Warm-up routine for http applications over REST and gRPC
Go
62
star
14

avro-compatibility

A user friendly API for checking for and reporting on Avro schema incompatibilities.
Java
56
star
15

expediagroup.github.io

The Expedia Group Open Source portal, a website for discovering EG open source projects.
JavaScript
53
star
16

graphql-component

Composeable graphql components
JavaScript
53
star
17

heat

Heat Test Framework
Java
46
star
18

beekeeper

Service for automatically managing and cleaning up unreferenced data
Java
45
star
19

pitchfork

Convert tracing data between Zipkin and Haystack formats
Java
44
star
20

apiary

Apiary provides modules which can be combined to create a federated cloud data lake
35
star
21

pino-rotating-file

[DEPRECATED] A pino log transport for splitting logs into separate, automatically rotating files.
JavaScript
32
star
22

github-helpers

A collection of Github Actions that simplify and standardize common CI/CD workflow tasks.
TypeScript
30
star
23

vsync

Sync Secrets between HashiCorp vaults
Go
29
star
24

javro

JSON Schema to Avro Mapper
JavaScript
28
star
25

rhapsody

Reactive Streams framework with support for at-least-once processing
Java
28
star
26

plunger

A unit testing framework for the Cascading data processing platform.
Java
26
star
27

kube-graffiti

Paint your kubernetes objects with 'mutating' webhooks
Go
26
star
28

hiveberg

Demonstration of a Hive Input Format for Iceberg
Java
26
star
29

beeju

JUnit integration for testing the Apache Hive Metastore and HiveServer2 Thrift APIs
Java
24
star
30

react-event-tracking

React shared context utilities for analytic event tracking.
JavaScript
23
star
31

expediagroup.github.io-old

Expedia Group OSS Portal
HTML
23
star
32

shunting-yard

Shunting Yard is a real-time data replication tool that copies data between Hive Metastores.
Java
20
star
33

jasvorno

A library for strong, schema based conversion between 'natural' JSON documents and Avro
Java
18
star
34

apiary-data-lake

Terraform scripts for deploying Apiary Data Lake
HCL
18
star
35

datasqueeze

Hadoop utility to compact small files
Java
18
star
36

hello-streams

hello-streams :: Introducing the stream-first mindset
Java
16
star
37

container-startup-autoscaler

A Kubernetes controller that modifies the CPU and/or memory resources of containers depending on whether they're starting up, according to the startup/post-startup settings you supply.
Go
16
star
38

map-maker

Map maker is a command line tool and library for easily generating maps from structured data.
Jupyter Notebook
15
star
39

spinnaker-pipeline-trigger

Pipeline trigger for Spinnaker utilizing SNS
TypeScript
15
star
40

corc

An ORC File Scheme for the Cascading data processing platform.
Java
14
star
41

steerage

[DEPRECATED] Hapi server configuration and composition using confidence, topo, and shortstop.
JavaScript
14
star
42

fpsmeter

Optimized javascript utility for measuring frames per second in a browser environment. Useful for observing end-user client run-time performance without adversly impacting performance.
JavaScript
14
star
43

insights-explorer

Insights Explorer is a tool to catalogue and present analytical & research work.
TypeScript
13
star
44

service-client

[DEPRECATED] A general purpose http client built with extensibility in mind. It also features lifecycle hooks, dynamic hostname resolution, and circuit breaking.
JavaScript
12
star
45

molten

Molten is an opinionated library providing reactive tooling to simplify building production-ready integration solutions using Reactor.
Java
12
star
46

apiary-extensions

Extensions available for use in Apiary
Java
10
star
47

drone-fly

A service which allows Hive Metastore Listeners to be deployed outside of the Hive Metastore Service
Java
10
star
48

github-webhook-proxy

Request forwarder for GitHub webhooks from github.com to internal enterprise destinations, designed for use in Github Enterprise Cloud.
TypeScript
9
star
49

secrets-injector

Go
9
star
50

neaps

a simulator to forecast the end of agile project basing on historical data and using montecarlo simulations
JavaScript
9
star
51

cypress-codegen

A Cypress plugin which automatically adds and enables IntelliSense for your custom commands!
TypeScript
9
star
52

circus-train-bigquery

Circus Train plugin which replicates BigQuery tables to Hive
Java
8
star
53

quibble

Data validator tool to allows testers, developers and analysts to define and execute test-cases involving data. Quibble is able to compare data from one or more data platforms, assert on the outcome and produce generated report output on any anomalies in data.
Java
8
star
54

dr-shadow

Dr Shadow is a library developed by Egencia (part of Expedia Group) that enables shadow traffic (ie. mirroring). It is a valuable tool for having good hygiene for service operations (ie. testing, resiliency, performance).
Java
6
star
55

hello-cloud

hello world example for Multicloud applications
HTML
6
star
56

flyte-client

A Go library designed to make the writing of flyte packs simple
Go
6
star
57

catalyst-server

[DEPRECATED] Configuration and composition management for Hapi.js applications.
JavaScript
6
star
58

aws-adfs-login

Library for user login (client side) using AWS ADFS (Active Directory Federation Service)
Go
5
star
59

comparadise

A visual comparison tool for reviewing visual changes on frontend PRs.
TypeScript
5
star
60

apiary-metastore-docker

Docker image for Apiary Data Lake metastore
Shell
5
star
61

apiary-ranger-docker

Docker image for Apiary Data Lake Ranger
Shell
4
star
62

flyte-jira

An Atlassian Jira integration pack for Flyte
Go
4
star
63

kafka-consumer-sns-sqs

Kafka Consumer for AWS SNS/SQS
Python
4
star
64

catalyst-render

[DEPRECATED] A hapi js plugin that works with catalyst-server to provide server-side rendering with react inside a handlebars template
JavaScript
4
star
65

expediagroup-python-sdk

Open World SDK for Python
Python
4
star
66

nimbuild

A suite of build tools that enable ultra fast web bundling at run-time.
JavaScript
4
star
67

circus-train-datasqueeze

Circus Train ⨉ DataSqueeze
Java
4
star
68

apiary-federation

Terraform scripts for deploying Apiary Data Lake federation
HCL
4
star
69

data-highway

Java
4
star
70

two-tower-lodging-candidate-generation

Python
4
star
71

flyte-bamboo

An Atlassian Bamboo integration pack for Flyte
Go
4
star
72

housekeeping

Common functionality for managing and cleaning up orphaned paths
Java
3
star
73

pkdd22-challenge-expediagroup

Expedia Group ECML/PKDD 2022 challenge
Python
3
star
74

icf

Independent connectivity forum API and tools
3
star
75

expediagroup-java-sdk

Open World SDK for Java.
Kotlin
3
star
76

hcommon-hive-metastore

General purpose libraries for interacting with the HiveMetaStore
Java
3
star
77

flyte-shell

Run shell scripts in your Flyte flows with this integration pack
Go
3
star
78

apiary-lifecycle

Terraform deployment scripts for Beekeeper
HCL
3
star
79

apiary-authorization

Authorization for Apiary Data Lake
HCL
3
star
80

flyte-serf

A Hashicorp Serf integration pack for Flyte
Go
3
star
81

network-plugin

The Network plugin allows developers to proxy requests and view the request and responses in IntelliJ.
Kotlin
3
star
82

a11y-tools

Client side A11y tools for trapping and tracking user focus.
JavaScript
2
star
83

flyte-ldap

An LDAP integration pack for Flyte
Go
2
star
84

new-project

This repository contains a template you can use to seed a repository for a new open source project.
2
star
85

expediagroup-nodejs-sdk

Expedia Group SDK for Node.js
TypeScript
2
star
86

apiary-drone-fly

Terraform scripts for deploying Drone Fly
HCL
2
star
87

dropwizard-resilience4j-bundle

Integration of Resilience4J into Dropwizard
Java
2
star
88

expediagroup-java-sdk-parent

2
star
89

parsec

Parsec is a data processing engine for interpreted queries.
Clojure
2
star
90

renovate-config-catalyst

[DEPRECATED] Renovate shared configuration for catalyst projects
2
star
91

flyte-slack

A Slack integration pack for Flyte
Go
2
star
92

openworld-sdk-java-generators

Mustache
2
star
93

flyte-graphite

A graphite integration pack for Flyte
Go
2
star
94

overwhelm

Operator for complex application deployment on Kubernetes
Go
2
star
95

package-json-validator

A Github Action for validating package.json conventions.
TypeScript
2
star
96

graphql-kotlin-codegen

A graphql-codegen plugin that enables type generation for GraphQL Kotlin services, promoting schema-first development.
TypeScript
2
star
97

helm-charts

Expedia Group Helm Charts
Mustache
1
star
98

determination

[DEPRECATED] Configuration resolver using confidence and shortstop.
JavaScript
1
star
99

dr-squid

Dr Squid is a downstream services and databases mocking tool primarily used for chaos testing and gathering performance metrics for Java Spring service
Java
1
star
100

spec-transformer

The API Spec Transformer Library
TypeScript
1
star