Repository URL to install this package:
|
Version:
1.10.0 ▾
|
const currentBranch = require('current-git-branch');
const chalk = require('chalk');
const open = require('open');
const path = require('path');
/**
* Launch the Jenkins job for the current repo and branch
*/
module.exports = () => {
/**
* Store all of the known exceptions where the Jenkins job names do not equal the repo name.
* @enum {String}
* @readonly
*/
const projectMappings = {
doodle: 'monolith-2',
};
try {
const BRANCH = currentBranch();
const JENKINS_BASE = 'https://builder.internal.doodle-test.com';
let REPO = path.basename(process.cwd());
// If the repo name is not the same as the Jenkins job name
// then we will look for the exceptions and update the repo name
// to be the correct Jenkins name
if (projectMappings[REPO]) {
REPO = projectMappings[REPO];
}
const url = `${JENKINS_BASE}/job/${REPO}/job/${BRANCH}/`;
console.log(chalk.yellow('Opening Jenkins URL:'), url);
open(url);
} catch (err) {
console.log(`Could not open jenkins job: ${err}`);
}
};