40 lines
4.8 KiB
JavaScript
40 lines
4.8 KiB
JavaScript
"use strict";
|
|
require("typings-global");
|
|
var plugins = require("./npmci.plugins");
|
|
var env = require("./npmci.env");
|
|
exports.build = function (commandArg) {
|
|
switch (commandArg) {
|
|
case "docker":
|
|
return docker();
|
|
case "docker-gitlab":
|
|
return dockerGitlab();
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
var docker = function () {
|
|
var done = plugins.q.defer();
|
|
plugins.shelljs.exec("docker build -t " + env.repo.user + "/" + env.repo.repo + ":latest .");
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
var dockerGitlab = function () {
|
|
var done = plugins.q.defer();
|
|
var repo = new plugins.smartstring.GitRepo(process.env.CI_BUILD_REPO);
|
|
var dockerTag = "registry.gitlab.com/" + env.repo.user + "/" + env.repo.repo + ":" + dockerTagVersion() + " .";
|
|
plugins.beautylog.info("now building docker image with tag " + dockerTag);
|
|
plugins.shelljs.exec("docker build -t " + dockerTag);
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
var dockerTagVersion = function () {
|
|
if (process.env.CI_BUILD_STAGE == "test") {
|
|
return "test";
|
|
}
|
|
else {
|
|
return "latest";
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJ1aWxkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsSUFBWSxPQUFPLFdBQU0saUJBQWlCLENBQUMsQ0FBQTtBQUUzQyxJQUFZLEdBQUcsV0FBTSxhQUFhLENBQUMsQ0FBQTtBQUV4QixhQUFLLEdBQUcsVUFBUyxVQUFVO0lBQ2xDLE1BQU0sQ0FBQSxDQUFDLFVBQVUsQ0FBQyxDQUFBLENBQUM7UUFDZixLQUFLLFFBQVE7WUFDVCxNQUFNLENBQUMsTUFBTSxFQUFFLENBQUM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