add some functions
This commit is contained in:
parent
42d3ecbe37
commit
e1245f24ce
16
dist/npmci.build.js
vendored
16
dist/npmci.build.js
vendored
@ -14,16 +14,26 @@ exports.build = function (commandArg) {
|
|||||||
};
|
};
|
||||||
var docker = function () {
|
var docker = function () {
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
plugins.shelljs.exec("docker build -t " + "registry.gitlab.com/" + env.repo.user + "/" + env.repo.repo + ":latest .");
|
plugins.shelljs.exec("docker build -t " + env.repo.user + "/" + env.repo.repo + ":latest .");
|
||||||
done.resolve();
|
done.resolve();
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
var dockerGitlab = function () {
|
var dockerGitlab = function () {
|
||||||
var done = plugins.q.defer();
|
var done = plugins.q.defer();
|
||||||
var repo = new plugins.smartstring.GitRepo(process.env.CI_BUILD_REPO);
|
var repo = new plugins.smartstring.GitRepo(process.env.CI_BUILD_REPO);
|
||||||
plugins.shelljs.exec("docker build -t " + "registry.gitlab.com/" + env.repo.user + "/" + env.repo.repo + ":latest .");
|
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();
|
done.resolve();
|
||||||
return done.promise;
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLmJ1aWxkLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7Q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7,13 @@ export let build = function(commandArg){
|
|||||||
switch(commandArg){
|
switch(commandArg){
|
||||||
case "docker":
|
case "docker":
|
||||||
return docker();
|
return docker();
|
||||||
case "docker-gitlab":
|
|
||||||
return dockerGitlab();
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let docker = function(){
|
let docker = function(){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.shelljs.exec("docker build -t " + "registry.gitlab.com/" + env.repo.user + "/" + env.repo.repo + ":latest .");
|
plugins.shelljs.exec("docker build -t " + env.dockerTag());
|
||||||
done.resolve();
|
done.resolve();
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dockerGitlab = function(){
|
|
||||||
let done = plugins.q.defer();
|
|
||||||
let repo = new plugins.smartstring.GitRepo(process.env.CI_BUILD_REPO);
|
|
||||||
plugins.shelljs.exec("docker build -t " + "registry.gitlab.com/" + env.repo.user + "/" + env.repo.repo + ":latest .");
|
|
||||||
done.resolve();
|
|
||||||
return done.promise;
|
|
||||||
}
|
|
@ -6,3 +6,25 @@ import {GitRepo} from "smartstring";
|
|||||||
export let repo = new GitRepo(process.env.CI_BUILD_REPO);
|
export let repo = new GitRepo(process.env.CI_BUILD_REPO);
|
||||||
export let dockerTestTag:string;
|
export let dockerTestTag:string;
|
||||||
export let dockerReleaseTag:string;
|
export let dockerReleaseTag:string;
|
||||||
|
|
||||||
|
export let dockerRegistry = "docker.io"; // will be set by npmci.prepare
|
||||||
|
|
||||||
|
export let dockerTagVersion = function(){
|
||||||
|
if(process.env.CI_BUILD_STAGE == "test"){
|
||||||
|
return "test";
|
||||||
|
} else {
|
||||||
|
return "latest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let dockerTag = function(){
|
||||||
|
return dockerRegistry + "/" + repo.user + "/" + repo.repo + ":" + dockerTagVersion() +" .";
|
||||||
|
}
|
||||||
|
|
||||||
|
export let dockerTagTest = function(){
|
||||||
|
return dockerRegistry + "/" + repo.user + "/" + repo.repo + ":test .";
|
||||||
|
}
|
||||||
|
|
||||||
|
export let dockerTagRelease = function(){
|
||||||
|
return dockerRegistry + "/" + repo.user + "/" + repo.repo + ":latest .";
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
import * as plugins from "./npmci.plugins";
|
import * as plugins from "./npmci.plugins";
|
||||||
import {bash} from "./npmci.bash";
|
import {bash} from "./npmci.bash";
|
||||||
|
import * as env from "./npmci.env"
|
||||||
|
|
||||||
let npm = function(){
|
let npm = function(){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
@ -22,6 +23,7 @@ let npm = function(){
|
|||||||
|
|
||||||
let docker = function(){
|
let docker = function(){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
env.dockerRegistry = "docker.io"
|
||||||
let dockerRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)/
|
let dockerRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)/
|
||||||
if(!process.env.NPMCI_LOGIN_DOCKER){
|
if(!process.env.NPMCI_LOGIN_DOCKER){
|
||||||
plugins.beautylog.error("You have to specify Login Data to the Docker Registry");
|
plugins.beautylog.error("You have to specify Login Data to the Docker Registry");
|
||||||
@ -37,6 +39,7 @@ let docker = function(){
|
|||||||
|
|
||||||
let dockerGitlab = function(){
|
let dockerGitlab = function(){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
env.dockerRegistry = "registry.gitlab.io"
|
||||||
let ciBuildToken = process.env.CI_BUILD_TOKEN
|
let ciBuildToken = process.env.CI_BUILD_TOKEN
|
||||||
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + ciBuildToken + " registry.gitlab.com");
|
plugins.shelljs.exec("docker login -u gitlab-ci-token -p " + ciBuildToken + " registry.gitlab.com");
|
||||||
done.resolve();
|
done.resolve();
|
||||||
|
@ -4,21 +4,12 @@ import {prepare} from "./npmci.prepare";
|
|||||||
import {bash} from "./npmci.bash";
|
import {bash} from "./npmci.bash";
|
||||||
|
|
||||||
export let publish = (serviceArg:string = "npm") => {
|
export let publish = (serviceArg:string = "npm") => {
|
||||||
let done = plugins.q.defer();
|
|
||||||
switch (serviceArg){
|
switch (serviceArg){
|
||||||
case "npm":
|
case "npm":
|
||||||
publishNpm()
|
return publishNpm();
|
||||||
.then(function(){
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case "docker":
|
case "docker":
|
||||||
publishDocker()
|
return publishDocker();
|
||||||
.then(function(){
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return done.promise;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let publishNpm = function(){
|
let publishNpm = function(){
|
||||||
@ -36,7 +27,8 @@ let publishDocker = function(){
|
|||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
prepare("docker")
|
prepare("docker")
|
||||||
.then(function(){
|
.then(function(){
|
||||||
bash("docker push");
|
bash
|
||||||
|
bash("docker push ");
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
|
Loading…
Reference in New Issue
Block a user