Created
August 22, 2017 06:44
-
-
Save idoshamun/cfd745d3370f1bddf6b6a41c25d55527 to your computer and use it in GitHub Desktop.
BrowserStack integration with Jenkins
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
def call(body) { | |
lock(label: 'BrowserStack', quantity: 1) { | |
env.BROWSERSTACK_LOCAL_IDENTIFIER = env.BUILD_TAG | |
// Start the connection | |
sh "BUILD_ID=dontKillMe nohup /opt/BrowserStackLocal --force-local --only-automate --key ${env.BROWSERSTACK_ACCESSKEY} --local-identifier ${env.BROWSERSTACK_LOCAL_IDENTIFIER} > /var/tmp/browserstack.log 2>&1 & echo \$! > /var/tmp/browserstack.pid" | |
try { | |
body() | |
} | |
finally { | |
// Stop the connection | |
sh "kill `cat /var/tmp/browserstack.pid`" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a snippet from our Jenkins shared library which is currently closed source.
It assumes that
BrowserStackLocal
is installed in/opt
directory and that the BrowserStack access key is available via environment variableBROWSERSTACK_ACCESSKEY
.In addition, in order to limit the parallel jobs that can use BrowserStack due to billing issue I use Lockable Resources Plugin.