Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
BrowserStack integration with Jenkins
#!/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`"
}
}
}
@idoshamun

This comment has been minimized.

Copy link
Owner Author

@idoshamun idoshamun commented Aug 22, 2017

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 variable BROWSERSTACK_ACCESSKEY.
In addition, in order to limit the parallel jobs that can use BrowserStack due to billing issue I use Lockable Resources Plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment