65 lines
5.4 KiB
JavaScript
65 lines
5.4 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.setDockerRegistry("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.setDockerRegistry("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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