Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@doodle/doodle-node-cli / src / prompts / jenkins-prompt.js
Size: Mime:
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}`);
  }
};