Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- config parameter for controlling the video recording during test execution (#11)

## [v2.0.0](https://github.com/cloudogu/zalenium-build-lib/releases/tag/v2.0.0) - 2020-02-21

Heads-up: Breaking change ahead!
Expand Down
35 changes: 20 additions & 15 deletions vars/withZalenium.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@
*
* @param config contains a map of settings that change the Zalenium behavior. Can be a partial map or even left out.
* The defaults are:
* [seleniumVersion : '3.141.59-p8',
* seleniumImage : 'elgalu/selenium',
* zaleniumVersion : '3.141.59g',
* zaleniumImage : 'dosel/zalenium',
* zaleniumVideoDir : 'zalenium',
* sendGoogleAnalytics: false,
* debugZalenium : false]
* [seleniumVersion : '3.141.59-p8',
* seleniumImage : 'elgalu/selenium',
* zaleniumVersion : '3.141.59g',
* zaleniumImage : 'dosel/zalenium',
* zaleniumVideoDir : 'zalenium',
* debugZalenium : false,
* videoRecordingEnabled: false,
* sendGoogleAnalytics : false]
* @param zaleniumNetwork The Zalenium container will be added to this docker network. This is useful if other containers
* must communicate with Zalenium while being in a docker network. If empty or left out, Zalenium will stay in the
* default network.
* @param closure the body
*/
void call(Map config = [:], String zaleniumNetwork, Closure closure) {

def defaultConfig = [seleniumVersion : '3.141.59-p8',
seleniumImage : 'elgalu/selenium',
zaleniumVersion : '3.141.59g',
zaleniumImage : 'dosel/zalenium',
zaleniumVideoDir : 'zalenium',
debugZalenium : false,
sendGoogleAnalytics: false]
def defaultConfig = [seleniumVersion : '3.141.59-p8',
seleniumImage : 'elgalu/selenium',
zaleniumVersion : '3.141.59g',
zaleniumImage : 'dosel/zalenium',
zaleniumVideoDir : 'zalenium',
debugZalenium : false,
videoRecordingEnabled: false,
sendGoogleAnalytics : false]

// Merge default config with the one passed as parameter
config = defaultConfig << config
Expand Down Expand Up @@ -58,6 +60,7 @@ void call(Map config = [:], String zaleniumNetwork, Closure closure) {
"-v ${WORKSPACE}/${config.zaleniumVideoDir}:/home/seluser/videos",
'start ' +
"--seleniumImageName ${config.seleniumImage} " +
"--videoRecordingEnabled ${config.videoRecordingEnabled} " +
"${config.debugZalenium ? '--debugEnabled true' : ''} " +
// switch off analytic gathering
"${config.sendGoogleAnalytics ? '--sendAnonymousUsageInfo false' : ''} "
Expand All @@ -77,7 +80,9 @@ void call(Map config = [:], String zaleniumNetwork, Closure closure) {
// Wait for Selenium sessions to end (i.e. videos to be copied)
// Leaving the withRun() closure leads to "docker rm -f" being called, cancelling copying
waitForSeleniumSessionsToEnd(zaleniumIp)
archiveArtifacts allowEmptyArchive: true, artifacts: "${config.zaleniumVideoDir}/*.mp4"
if(config.videoRecordingEnabled) {
archiveArtifacts allowEmptyArchive: true, artifacts: "${config.zaleniumVideoDir}/*.mp4"
}

// Stop container gracefully and wait
sh "docker stop ${zaleniumContainer.id}"
Expand Down
1 change: 1 addition & 0 deletions vars/withZalenium.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Requires Docker!
- zaleniumVersion - version of the zalenium docker image
- zaleniumVideoDir - path where the videos are stored, relative to the Jenkins workspace.
- debugZalenium - makes the zalenium container write a lot more logs
- videoRecordingEnabled - enables the video recording during the test execution; defaults to false
- sendGoogleAnalytics - if true this will send analytic data to Google/Zalando

Exemplary calls:
Expand Down