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-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);
|
|
|
|
}
|
|
|
|
plugins.smartfile.memory.toFsSync(npmrcFileString, { fileName: ".npmrc", filePath: "/root" });
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
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-02 23:58:37 +00:00
|
|
|
var ciBuildToken = process.env.CI_BUILD_TOKEN;
|
2016-06-03 15:25:29 +00:00
|
|
|
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + ciBuildToken + " " + env.dockerRegistry);
|
2016-06-01 03:44:48 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
|
|
|
};
|
|
|
|
exports.prepare = function (serviceArg) {
|
|
|
|
switch (serviceArg) {
|
|
|
|
case "npm":
|
|
|
|
return npm();
|
|
|
|
case "docker":
|
2016-06-05 02:48:39 +00:00
|
|
|
return docker()
|
|
|
|
.then(dockerGitlab); // always also login to gitlab registry for tests
|
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-05 02:48:39 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnByZXBhcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFZLE9BQU8sV0FBTSxpQkFBaUIsQ0FBQyxDQUFBO0FBRTNDLElBQVksR0FBRyxXQUFNLGFBRXJCLENBQUMsQ0FGaUM7QUFFbEMsSUFBSSxHQUFHLEdBQUc7SUFDTixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBRTdCLElBQUksV0FBVyxHQUFVLG1DQUFtQyxDQUFDO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