65 lines
5.3 KiB
JavaScript
65 lines
5.3 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
const plugins = require("./npmci.plugins");
|
|
const env = require("./npmci.env");
|
|
const sshModule = require("./npmci.ssh");
|
|
let npm = function () {
|
|
let done = plugins.q.defer();
|
|
let npmrcPrefix = "//registry.npmjs.org/:_authToken=";
|
|
let npmToken = process.env.NPMCI_TOKEN_NPM;
|
|
let npmrcFileString = npmrcPrefix + npmToken;
|
|
if (npmToken) {
|
|
plugins.beautylog.info("found access token");
|
|
}
|
|
else {
|
|
plugins.beautylog.error("no access token found! Exiting!");
|
|
process.exit(1);
|
|
}
|
|
plugins.smartfile.memory.toFsSync(npmrcFileString, "/root/.npmrc");
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let docker = function () {
|
|
let done = plugins.q.defer();
|
|
env.dockerRegistry = "docker.io";
|
|
let dockerRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)/;
|
|
if (!process.env.NPMCI_LOGIN_DOCKER) {
|
|
plugins.beautylog.error("You have to specify Login Data to the Docker Registry");
|
|
process.exit(1);
|
|
}
|
|
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + process.env.CI_BUILD_TOKEN + " " + "registry.gitlab.com"); // Always also login to GitLab Registry
|
|
let dockerRegexResultArray = dockerRegex.exec(process.env.NPMCI_LOGIN_DOCKER);
|
|
let username = dockerRegexResultArray[1];
|
|
let password = dockerRegexResultArray[2];
|
|
plugins.shelljs.exec("docker login -u " + username + " -p " + password);
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let dockerGitlab = function () {
|
|
let done = plugins.q.defer();
|
|
env.dockerRegistry = "registry.gitlab.com";
|
|
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + process.env.CI_BUILD_TOKEN + " " + "registry.gitlab.com");
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let ssh = function () {
|
|
let done = plugins.q.defer();
|
|
sshModule.ssh()
|
|
.then(done.resolve);
|
|
return done.promise;
|
|
};
|
|
exports.prepare = function (serviceArg) {
|
|
switch (serviceArg) {
|
|
case "npm":
|
|
return npm();
|
|
case "docker":
|
|
return docker();
|
|
case "docker-gitlab":
|
|
return dockerGitlab();
|
|
case "ssh":
|
|
return ssh();
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kucHJlcGFyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWNpLnByZXBhcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixNQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBRTNDLE1BQVksR0FBRyxXQUFNLGFBQ3JCLENBQUMsQ0FEaUM7QUFDbEMsTUFBWSxTQUFTLFdBQU0sYUFFM0IsQ0FBQyxDQUZ1QztBQUV4QyxJQUFJLEdBQUcsR0FBRztJQUNOLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFFN0IsSUFBSSxXQUFXLEdBQVUsbUNBQW1DLENBQUM7SUFDN0QsSUFBSSxRQUFRLEdBQVUsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUM7SUFDbEQsSUFBSSxlQUFlLEdBQUcsV0FBVyxHQUFHLFFBQVEsQ0FBQztJQUU3QyxFQUFFLENBQUEsQ0FBQyxRQUFRLENBQUMsQ0FBQSxDQUFDO1FBQ1QsT0FBTyxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsb0JBQW9CLENBQUMsQ0FBQztJQUNqRCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxpQ0FBaUMsQ0FBQyxD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