update docker login handling
This commit is contained in:
parent
30e16cb33d
commit
f1bf000744
32
dist/mod_prepare/index.js
vendored
32
dist/mod_prepare/index.js
vendored
@ -34,20 +34,26 @@ let npm = () => __awaiter(this, void 0, void 0, function* () {
|
|||||||
*/
|
*/
|
||||||
let docker = () => __awaiter(this, void 0, void 0, function* () {
|
let docker = () => __awaiter(this, void 0, void 0, function* () {
|
||||||
env.setDockerRegistry('docker.io'); // TODO: checkup why we set this here
|
env.setDockerRegistry('docker.io'); // TODO: checkup why we set this here
|
||||||
let dockerRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)/;
|
// handle other registries
|
||||||
// Login external reigstry
|
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_LOGIN_DOCKER*', (envString) => __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!process.env.NPMCI_LOGIN_DOCKER) {
|
let dockerRegexResultArray = process.env.NPMCI_LOGIN_DOCKER.split('|');
|
||||||
plugins.beautylog.warn('You have to specify Login Data to an external Docker Registry');
|
if (dockerRegexResultArray.length !== 3) {
|
||||||
plugins.beautylog.warn('|- As a result only the gitlab registry is availble for this build.');
|
plugins.beautylog.error('malformed docker env var...');
|
||||||
}
|
process.exit(1);
|
||||||
else {
|
return;
|
||||||
let dockerRegexResultArray = dockerRegex.exec(process.env.NPMCI_LOGIN_DOCKER);
|
}
|
||||||
|
let registry = dockerRegexResultArray[0];
|
||||||
let username = dockerRegexResultArray[1];
|
let username = dockerRegexResultArray[1];
|
||||||
let password = dockerRegexResultArray[2];
|
let password = dockerRegexResultArray[2];
|
||||||
yield npmci_bash_1.bash('docker login -u ' + username + ' -p ' + password);
|
if (registry === 'docker.io') {
|
||||||
}
|
yield npmci_bash_1.bash('docker login -u ' + username + ' -p ' + password);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
yield npmci_bash_1.bash(`docker login -u ${username} -p ${password} ${registry}`);
|
||||||
|
}
|
||||||
|
}));
|
||||||
// Always login to GitLab Registry
|
// Always login to GitLab Registry
|
||||||
plugins.shelljs.exec('docker login -u gitlab-ci-token -p ' + process.env.CI_BUILD_TOKEN + ' ' + 'registry.gitlab.com');
|
yield dockerGitlab();
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
@ -55,7 +61,7 @@ let docker = () => __awaiter(this, void 0, void 0, function* () {
|
|||||||
*/
|
*/
|
||||||
let dockerGitlab = () => __awaiter(this, void 0, void 0, function* () {
|
let dockerGitlab = () => __awaiter(this, void 0, void 0, function* () {
|
||||||
env.setDockerRegistry('registry.gitlab.com');
|
env.setDockerRegistry('registry.gitlab.com');
|
||||||
plugins.shelljs.exec('docker login -u gitlab-ci-token -p ' + process.env.CI_BUILD_TOKEN + ' ' + 'registry.gitlab.com');
|
yield npmci_bash_1.bash(`docker login -u gitlab-ci-token -p ${process.env.CI_BUILD_TOKEN} registry.gitlab.com`);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
@ -83,4 +89,4 @@ exports.prepare = (serviceArg) => __awaiter(this, void 0, void 0, function* () {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9tb2RfcHJlcGFyZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEseUNBQXdDO0FBQ3hDLDhDQUFvQztBQUNwQyxvQ0FBbUM7QUFDbkMsMkNBQTBDO0FBUzFDOztHQUVHO0FBQ0gsSUFBSSxHQUFHLEdBQUc7SUFDUixJQUFJLFdBQVcsR0FBVyxtQ0FBbUMsQ0FBQTtJQUM3RCxJQUFJLFFBQVEsR0FBVyxPQUFPLENBQUMsR0FBRyxDQUFDLGVBQWUsQ0FBQTtJQUNsRCxJQUFJLGVBQWUsR0F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sTUFBTSxFQUFFLENBQUE7UUFDdkIsS0FBSyxlQUFlO1lBQ2xCLE1BQU0sQ0FBQyxNQUFNLFlBQVksRUFBRSxDQUFBO1FBQzdCLEtBQUssS0FBSztZQUNSLE1BQU0sQ0FBQyxNQUFNLEdBQUcsRUFBRSxDQUFBO1FBQ3BCO1lBQ0UsS0FBSyxDQUFBO0lBQ1QsQ0FBQztBQUNILENBQUMsQ0FBQSxDQUFBIn0=
|
24
package.json
24
package.json
@ -22,34 +22,34 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/gitzone/npmci#README",
|
"homepage": "https://gitlab.com/gitzone/npmci#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tapbundle": "^1.0.14"
|
"tapbundle": "^1.1.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/lodash": "^4.14.67",
|
"@types/lodash": "^4.14.74",
|
||||||
"@types/node": "^8.0.6",
|
"@types/node": "^8.0.25",
|
||||||
"@types/shelljs": "^0.7.2",
|
"@types/shelljs": "^0.7.4",
|
||||||
"@types/through2": "^2.0.33",
|
"@types/through2": "^2.0.33",
|
||||||
"beautylog": "^6.1.10",
|
"beautylog": "^6.1.10",
|
||||||
"cflare": "^1.0.5",
|
"cflare": "^1.0.5",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-function": "^2.2.9",
|
"gulp-function": "^2.2.9",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"npmextra": "^2.0.5",
|
"npmextra": "^2.0.9",
|
||||||
"projectinfo": "^3.0.2",
|
"projectinfo": "^3.0.2",
|
||||||
"request": "^2.81.0",
|
"request": "^2.81.0",
|
||||||
"shelljs": "^0.7.8",
|
"shelljs": "^0.7.8",
|
||||||
"smartcli": "^2.0.7",
|
"smartcli": "^2.0.7",
|
||||||
"smartdelay": "^1.0.3",
|
"smartdelay": "^1.0.3",
|
||||||
"smartfile": "^4.2.17",
|
"smartfile": "^4.2.20",
|
||||||
"smartmonitor": "^1.0.3",
|
"smartmonitor": "^1.0.3",
|
||||||
"smartparam": "^0.1.1",
|
"smartparam": "^1.0.1",
|
||||||
"smartq": "^1.1.1",
|
"smartq": "^1.1.6",
|
||||||
"smartshell": "^1.0.8",
|
"smartshell": "^1.0.13",
|
||||||
"smartsocket": "^1.1.7",
|
"smartsocket": "^1.1.10",
|
||||||
"smartssh": "^1.2.2",
|
"smartssh": "^1.2.2",
|
||||||
"smartstring": "^2.0.24",
|
"smartstring": "^2.0.24",
|
||||||
"smartsystem": "^1.0.18",
|
"smartsystem": "^2.0.2",
|
||||||
"through2": "^2.0.3",
|
"through2": "^2.0.3",
|
||||||
"typings-global": "^1.0.19"
|
"typings-global": "^1.0.20"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,21 +32,27 @@ let npm = async () => {
|
|||||||
*/
|
*/
|
||||||
let docker = async () => {
|
let docker = async () => {
|
||||||
env.setDockerRegistry('docker.io') // TODO: checkup why we set this here
|
env.setDockerRegistry('docker.io') // TODO: checkup why we set this here
|
||||||
let dockerRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)/
|
|
||||||
|
|
||||||
// Login external reigstry
|
// handle other registries
|
||||||
if (!process.env.NPMCI_LOGIN_DOCKER) {
|
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_LOGIN_DOCKER*', async (envString) => {
|
||||||
plugins.beautylog.warn('You have to specify Login Data to an external Docker Registry')
|
let dockerRegexResultArray = process.env.NPMCI_LOGIN_DOCKER.split('|')
|
||||||
plugins.beautylog.warn('|- As a result only the gitlab registry is availble for this build.')
|
if (dockerRegexResultArray.length !== 3) {
|
||||||
} else {
|
plugins.beautylog.error('malformed docker env var...')
|
||||||
let dockerRegexResultArray = dockerRegex.exec(process.env.NPMCI_LOGIN_DOCKER)
|
process.exit(1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let registry = dockerRegexResultArray[0]
|
||||||
let username = dockerRegexResultArray[1]
|
let username = dockerRegexResultArray[1]
|
||||||
let password = dockerRegexResultArray[2]
|
let password = dockerRegexResultArray[2]
|
||||||
await bash('docker login -u ' + username + ' -p ' + password)
|
if (registry === 'docker.io') {
|
||||||
}
|
await bash('docker login -u ' + username + ' -p ' + password)
|
||||||
|
} else {
|
||||||
|
await bash(`docker login -u ${username} -p ${password} ${registry}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Always login to GitLab Registry
|
// Always login to GitLab Registry
|
||||||
plugins.shelljs.exec('docker login -u gitlab-ci-token -p ' + process.env.CI_BUILD_TOKEN + ' ' + 'registry.gitlab.com')
|
await dockerGitlab()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +61,7 @@ let docker = async () => {
|
|||||||
*/
|
*/
|
||||||
let dockerGitlab = async () => {
|
let dockerGitlab = async () => {
|
||||||
env.setDockerRegistry('registry.gitlab.com')
|
env.setDockerRegistry('registry.gitlab.com')
|
||||||
plugins.shelljs.exec('docker login -u gitlab-ci-token -p ' + process.env.CI_BUILD_TOKEN + ' ' + 'registry.gitlab.com')
|
await bash(`docker login -u gitlab-ci-token -p ${process.env.CI_BUILD_TOKEN} registry.gitlab.com`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user