Skip to content

Commit

Permalink
Merge pull request #6590 from spalger/upgrade/selenium
Browse files Browse the repository at this point in the history
[jenkins] ensure that JDK8 is in path
  • Loading branch information
spalger committed Mar 21, 2016
2 parents 1f2d966 + f53b8c1 commit 7f089c4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
10 changes: 7 additions & 3 deletions tasks/config/downloadSelenium.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
var path = require('path');
import { resolve as resolveUrl } from 'url';

const URL = 'https://selenium-release.storage.googleapis.com/2.48/selenium-server-standalone-2.48.2.jar';
const DIR = resolveUrl(URL, './');
const FILE = URL.replace(DIR, '');

module.exports = function (grunt) {
return {
options: {
selenium: {
filename: 'selenium-server-standalone-2.48.2.jar',
server: 'https://selenium-release.storage.googleapis.com/2.48/',
filename: FILE,
server: DIR,
md5: 'b2784fc67c149d3c13c83d2108104689',
directory: path.join(grunt.config.get('root'), 'selenium')
path: path.join(grunt.config.get('root'), 'selenium', FILE)
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions tasks/config/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = function (grunt) {
cmd: 'java',
args: [
'-jar',
'selenium/selenium-server-standalone-2.48.2.jar',
'<%= downloadSelenium.options.selenium.path %>',
'-port',
uiConfig.servers.webdriver.port,
]
Expand All @@ -138,7 +138,7 @@ module.exports = function (grunt) {
cmd: 'java',
args: [
'-jar',
'selenium/selenium-server-standalone-2.48.2.jar',
'<%= downloadSelenium.options.selenium.path %>',
'-port',
uiConfig.servers.webdriver.port,
]
Expand Down
19 changes: 10 additions & 9 deletions tasks/download_selenium.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ module.exports = function (grunt) {
const done = this.async();
const config = this.options();

const SELENIUM_FILE_PATH = path.join(config.selenium.directory, config.selenium.filename);
const SELENIUM_DOWNLOAD_URL = config.selenium.server + config.selenium.filename;
const FILE = config.selenium.path;
const DIR = path.dirname(config.selenium.path);
const URL = config.selenium.server + config.selenium.filename;

function validateDownload(path, expectedHash, success) {
grunt.log.write('Validating hash...');
Expand All @@ -28,27 +29,27 @@ module.exports = function (grunt) {
}

function downloadSelenium(success) {
grunt.log.write(`Downloading ${SELENIUM_DOWNLOAD_URL}...`);
request.get(SELENIUM_DOWNLOAD_URL)
.pipe(fs.createWriteStream(SELENIUM_FILE_PATH))
grunt.log.write(`Downloading ${URL}...`);
request.get(URL)
.pipe(fs.createWriteStream(FILE))
.on('error', function downloadError(err) {
grunt.fail.warn(err);
})
.on('finish', function downloadFinish() {
grunt.log.writeln('done');
validateDownload(SELENIUM_FILE_PATH, config.selenium.md5, success);
validateDownload(FILE, config.selenium.md5, success);
});
}

function start() {
try {
fs.mkdirSync(config.selenium.directory);
fs.mkdirSync(DIR);
} catch (err) {
if (err && err.code !== 'EEXIST') grunt.fail.warn(err);
}

if (fs.existsSync(SELENIUM_FILE_PATH)) {
validateDownload(SELENIUM_FILE_PATH, config.selenium.md5, done);
if (fs.existsSync(FILE)) {
validateDownload(FILE, config.selenium.md5, done);
} else {
downloadSelenium(done);
}
Expand Down
15 changes: 13 additions & 2 deletions tasks/jenkins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { compact } from 'lodash';
import { delimiter } from 'path';

module.exports = function (grunt) {
let { compact } = require('lodash');
grunt.registerTask('jenkins', 'Jenkins build script', function () {
process.env.JAVA_HOME = '/usr/lib/jvm/jdk8';
// make sure JAVA_HOME points to JDK8
const HOME = '/usr/lib/jvm/jdk8';
process.env.JAVA_HOME = HOME;

// extend PATH to point to JDK8
const path = process.env.PATH.split(delimiter);
path.unshift(`${HOME}/bin`);
process.env.PATH = path.join(delimiter);

// always build os packages on jenkins
grunt.option('os-packages', true);

grunt.task.run(compact([
Expand Down

0 comments on commit 7f089c4

Please sign in to comment.