2016-06-01 03:44:48 +00:00
|
|
|
"use strict";
|
|
|
|
require("typings-global");
|
|
|
|
var plugins = require("./npmci.plugins");
|
2016-06-03 14:27:12 +00:00
|
|
|
var env = require("./npmci.env");
|
2016-06-25 14:29:06 +00:00
|
|
|
var sshModule = require("./npmci.ssh");
|
2016-06-02 23:58:37 +00:00
|
|
|
var npm = function () {
|
|
|
|
var done = plugins.q.defer();
|
|
|
|
var npmrcPrefix = "//registry.npmjs.org/:_authToken=";
|
|
|
|
var npmToken = process.env.NPMCI_TOKEN_NPM;
|
|
|
|
var npmrcFileString = npmrcPrefix + npmToken;
|
|
|
|
if (npmToken) {
|
|
|
|
plugins.beautylog.info("found access token");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.error("no access token found! Exiting!");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2016-06-25 01:19:29 +00:00
|
|
|
plugins.smartfile.memory.toFsSync(npmrcFileString, "/root/.npmrc");
|
2016-06-02 23:58:37 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-06-01 03:44:48 +00:00
|
|
|
var docker = function () {
|
2016-06-02 11:08:15 +00:00
|
|
|
var done = plugins.q.defer();
|
2016-06-03 14:27:12 +00:00
|
|
|
env.dockerRegistry = "docker.io";
|
2016-06-02 11:08:15 +00:00
|
|
|
var dockerRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)/;
|
2016-06-02 15:57:01 +00:00
|
|
|
if (!process.env.NPMCI_LOGIN_DOCKER) {
|
|
|
|
plugins.beautylog.error("You have to specify Login Data to the Docker Registry");
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2016-06-05 22:00:50 +00:00
|
|
|
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + process.env.CI_BUILD_TOKEN + " " + "registry.gitlab.com"); // Always also login to GitLab Registry
|
2016-06-02 15:57:01 +00:00
|
|
|
var dockerRegexResultArray = dockerRegex.exec(process.env.NPMCI_LOGIN_DOCKER);
|
2016-06-02 11:08:15 +00:00
|
|
|
var username = dockerRegexResultArray[1];
|
|
|
|
var password = dockerRegexResultArray[2];
|
2016-06-02 17:47:57 +00:00
|
|
|
plugins.shelljs.exec("docker login -u " + username + " -p " + password);
|
2016-06-02 11:08:15 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
2016-06-01 03:44:48 +00:00
|
|
|
};
|
2016-06-02 23:58:37 +00:00
|
|
|
var dockerGitlab = function () {
|
2016-06-01 03:44:48 +00:00
|
|
|
var done = plugins.q.defer();
|
2016-06-03 17:45:34 +00:00
|
|
|
env.dockerRegistry = "registry.gitlab.com";
|
2016-06-05 22:00:50 +00:00
|
|
|
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + process.env.CI_BUILD_TOKEN + " " + "registry.gitlab.com");
|
2016-06-01 03:44:48 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-06-25 14:29:06 +00:00
|
|
|
var ssh = function () {
|
|
|
|
var done = plugins.q.defer();
|
|
|
|
sshModule.ssh()
|
|
|
|
.then(done.resolve);
|
|
|
|
return done.promise;
|
|
|
|
};
|
2016-06-01 03:44:48 +00:00
|
|
|
exports.prepare = function (serviceArg) {
|
|
|
|
switch (serviceArg) {
|
|
|
|
case "npm":
|
|
|
|
return npm();
|
|
|
|
case "docker":
|
2016-06-05 22:00:50 +00:00
|
|
|
return docker();
|
2016-06-02 23:58:37 +00:00
|
|
|
case "docker-gitlab":
|
|
|
|
return dockerGitlab();
|
|
|
|
default:
|
|
|
|
break;
|
2016-06-01 03:44:48 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-06-25 14:29:06 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnByZXBhcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQU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