• Stars
    star
    174
  • Rank 200,690 (Top 5 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated 10 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,612
star
2

cyclotron

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

styx

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

adaptive-alerting

Anomaly detection for streaming time series, featuring automated model selection.
Java
187
star
5

bull

BULL - Bean Utils Light Library
Java
176
star
6

waggle-dance

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

c3vis

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

stream-registry

Stream Discovery and Stream Orchestration
Java
109
star
9

jarviz

Jarviz is dependency analysis and visualization tool designed for Java applications
Java
98
star
10

flyte

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

circus-train

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

kubernetes-sidecar-injector

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

mittens

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

avro-compatibility

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

graphql-component

Composeable graphql components
JavaScript
51
star
16

heat

Heat Test Framework
Java
44
star
17

beekeeper

Service for automatically managing and cleaning up unreferenced data
Java
44
star
18

pitchfork

Convert tracing data between Zipkin and Haystack formats
Java
42
star
19

expediagroup.github.io

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

vsync

Sync Secrets between HashiCorp vaults
Go
28
star
21

apiary

Apiary provides modules which can be combined to create a federated cloud data lake
27
star
22

rhapsody

Reactive Streams framework with support for at-least-once processing
Java
27
star
23

kube-graffiti

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

pino-rotating-file

A pino log transport for splitting logs into separate, automatically rotating files.
JavaScript
26
star
25

plunger

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

github-helpers

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

javro

JSON Schema to Avro Mapper
JavaScript
24
star
28

beeju

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

hiveberg

Demonstration of a Hive Input Format for Iceberg
Java
24
star
30

expediagroup.github.io-old

Expedia Group OSS Portal
HTML
23
star
31

react-event-tracking

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

shunting-yard

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

jasvorno

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

datasqueeze

Hadoop utility to compact small files
Java
18
star
35

apiary-data-lake

Terraform scripts for deploying Apiary Data Lake
HCL
17
star
36

hello-streams

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

spinnaker-pipeline-trigger

Pipeline trigger for Spinnaker utilizing SNS
TypeScript
16
star
38

corc

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

steerage

Hapi server configuration and composition using confidence, topo, and shortstop.
JavaScript
14
star
40

map-maker

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

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
13
star
42

molten

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

service-client

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

insights-explorer

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

apiary-extensions

Extensions available for use in Apiary
Java
10
star
46

secrets-injector

Go
9
star
47

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
48

neaps

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

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
50

drone-fly

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

circus-train-bigquery

Circus Train plugin which replicates BigQuery tables to Hive
Java
7
star
52

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
53

hello-cloud

hello world example for Multicloud applications
HTML
6
star
54

flyte-client

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

catalyst-server

Configuration and composition management for Hapi.js applications.
JavaScript
6
star
56

aws-adfs-login

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

cypress-codegen

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

apiary-metastore-docker

Docker image for Apiary Data Lake metastore
Shell
5
star
59

apiary-ranger-docker

Docker image for Apiary Data Lake Ranger
Shell
4
star
60

flyte-bamboo

An Atlassian Bamboo integration pack for Flyte
Go
4
star
61

flyte-jira

An Atlassian Jira integration pack for Flyte
Go
4
star
62

openworld-sdk-python

Open World SDK for Python
Python
4
star
63

nimbuild

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

apiary-federation

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

data-highway

Java
4
star
66

circus-train-datasqueeze

Circus Train ⨉ DataSqueeze
Java
4
star
67

housekeeping

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

pkdd22-challenge-expediagroup

Expedia Group ECML/PKDD 2022 challenge
Python
3
star
69

icf

Independent connectivity forum API and tools
3
star
70

apiary-lifecycle

Terraform deployment scripts for Beekeeper
HCL
3
star
71

catalyst-render

A hapi js plugin that works with catalyst-server to provide server-side rendering with react inside a handlebars template
JavaScript
3
star
72

flyte-serf

A Hashicorp Serf integration pack for Flyte
Go
3
star
73

openworld-sdk-java-deprecated

Makefile
3
star
74

openworld-sdk-java

Open World SDK for Java.
Kotlin
3
star
75

flyte-shell

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

apiary-authorization

Authorization for Apiary Data Lake
HCL
3
star
77

openworld-sdk-java-generators

Mustache
3
star
78

comparadise

A visual comparison tool for reviewing visual changes on frontend PRs.
TypeScript
3
star
79

network-plugin

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

package-json-validator

A Github Action for validating package.json conventions.
TypeScript
3
star
81

a11y-tools

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

determination

Configuration resolver using confidence and shortstop.
JavaScript
2
star
83

flyte-slack

A Slack integration pack for Flyte
Go
2
star
84

flyte-ldap

An LDAP integration pack for Flyte
Go
2
star
85

new-project

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

kafka-consumer-sns-sqs

Kafka Consumer for AWS SNS/SQS
Python
2
star
87

expediagroup-nodejs-sdk

Expedia Group SDK for Node.js
TypeScript
2
star
88

apiary-drone-fly

Terraform scripts for deploying Drone Fly
HCL
2
star
89

dropwizard-resilience4j-bundle

Integration of Resilience4J into Dropwizard
Java
2
star
90

parsec

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

renovate-config-catalyst

Renovate shared configuration for catalyst projects
2
star
92

flyte-graphite

A graphite integration pack for Flyte
Go
2
star
93

overwhelm

Operator for complex application deployment on Kubernetes
Go
2
star
94

helm-charts

Expedia Group Helm Charts
Mustache
1
star
95

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
96

flyte-email

An email integration pack for Flyte
Go
1
star
97

hcommon-hive-metastore

General purpose libraries for interacting with the HiveMetaStore
Java
1
star
98

spec-transformer

The API Spec Transformer Library
TypeScript
1
star
99

proto-visual-exporter-plugin

A protoc plugin that takes in the protocol buffers schemas and outputs to your chosen visual exporter. Having a visual way of representing the schema is useful in seeing how types are being used.
Java
1
star
100

flyte-ticker

Pack implementing cron-like scheduling in Flyte flows
Go
1
star