File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ zalenium-build-lib
44=======
55
66Jenkins shared library that provides a step that runs a temporary [ zalenium server] ( https://github.com/zalando/zalenium )
7- in a via docker, that records videos of selenium tests. The videos are archived at the Jenkins job by this library.
7+ in docker container , that records videos of selenium tests. The videos are archived at the Jenkins job by this library.
88
99# Usage
1010
@@ -64,7 +64,7 @@ We use the `lock` step of the [Lockable Resources Plugin](https://wiki.jenkins.i
6464
6565# Troubleshooting
6666
67- The logs of the zalenium container are stored in $WORKSPACE/zalenium-docker.log.
67+ The logs of the zalenium container are stored in ` $WORKSPACE/zalenium-docker.log ` .
6868
6969You can enable debug logging like so:
7070
@@ -77,4 +77,8 @@ withZalenium([ debugZalenium : true ]) { zaleniumIp ->
7777# Examples
7878
7979* [ cloudogu/spring-petclinic] ( https://github.com/cloudogu/spring-petclinic/blob/548db42f320f0f9065876c588c93754beffacc36/Jenkinsfile ) (Java / Maven)
80- * [ cloudogu/nexus] ( https://github.com/cloudogu/nexus/blob/434c8c3ebef740cd887462aad1292971c46d883e/Jenkinsfile ) (JavaScript / yarn)
80+ * [ cloudogu/nexus] ( https://github.com/cloudogu/nexus/blob/434c8c3ebef740cd887462aad1292971c46d883e/Jenkinsfile ) (JavaScript / yarn)
81+ * [ cloudogu/jenkins] ( https://github.com/cloudogu/jenkins/blob/3bc8b6ab406477e0c3bb232e05f745b1fc91ba70/Jenkinsfile ) (JavaScript / yarn)
82+ * [ cloudogu/redmine] ( https://github.com/cloudogu/redmine/blob/740dd3a99a8111c31e4ada1ccb3023d84d6d205f/Jenkinsfile ) (JavaScript / yarn)
83+ * [ cloudogu/scm] ( https://github.com/cloudogu/scm/blob/4f1c998425e175a7a52f97dff5b78e82f244a9bf/Jenkinsfile ) (JavaScript / yarn)
84+ * [ cloudogu/sonar] ( https://github.com/cloudogu/sonar/blob/3488a6e7e38ee5e2e8fde807de570028e15835a1/Jenkinsfile ) (JavaScript / yarn)
Original file line number Diff line number Diff line change 22void call (config = [:], Closure closure ) {
33
44 def defaultConfig = [seleniumVersion : ' 3.141.59-p8' ,
5- zaleniumVersion : ' 3.141.59f ' ,
5+ zaleniumVersion : ' 3.141.59g ' ,
66 zaleniumVideoDir : " zalenium" ,
77 debugZalenium : false ]
88
@@ -15,9 +15,13 @@ void call(config = [:], Closure closure) {
1515 def zaleniumImage = docker. image(" dosel/zalenium:${ config.zaleniumVersion} " )
1616 zaleniumImage. pull()
1717
18- lock(" zalenium" ) {
18+ uid = findUid()
19+ gid = findGid()
1920
21+ lock(" zalenium" ) {
2022 zaleniumImage. withRun(
23+ // Run with Jenkins user, so the files created in the workspace by zalenium can be deleted later
24+ " -u ${ uid} :${ gid} -e HOST_UID=${ uid} -e HOST_GID=${ gid} " +
2125 // Zalenium starts headless browsers in docker containers, so it needs the socket
2226 ' -v /var/run/docker.sock:/var/run/docker.sock ' +
2327 " -v ${ WORKSPACE} /${ config.zaleniumVideoDir} :/home/seluser/videos" ,
@@ -58,6 +62,17 @@ String findContainerIp(container) {
5862 .trim()
5963}
6064
65+ String findUid () {
66+ sh (returnStdout : true ,
67+ script : ' id -u' )
68+ .trim()
69+ }
70+ String findGid () {
71+ sh (returnStdout : true ,
72+ script : ' id -g' )
73+ .trim()
74+ }
75+
6176void waitForSeleniumToGetReady (String host ) {
6277 timeout(time : 1 , unit : ' MINUTES' ) {
6378 echo " Waiting for selenium to become ready at http://${ host} "
You can’t perform that action at this time.
0 commit comments