buildnator-personal 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/buildnator.client.ts +30 -0
- package/dist/buildnator.client.js +48 -0
- package/package.json +1 -1
- package/types.ts +1 -0
package/buildnator.client.ts
CHANGED
|
@@ -15,6 +15,7 @@ const DEFAULT_JOBS: JobsConfig = {
|
|
|
15
15
|
publicarDllsNuget: "/job/GCS-AGB-Publicar-dlls-NuGet",
|
|
16
16
|
testeTaVersaoEvolutiva: "/job/QA%20-%20TA%20-%20AGB%20-%20TESTES%20AUTOMATIZADOS%20VERSAO%20EVOLUTIVA%20(GCS)",
|
|
17
17
|
unificarCommits: "/job/GCS-Unificar-commits",
|
|
18
|
+
criarbackup: "job/GCS-CriarBackup"
|
|
18
19
|
};
|
|
19
20
|
|
|
20
21
|
function normalizeBaseUrl(url: string): string {
|
|
@@ -470,4 +471,33 @@ export class BuildnatorClient {
|
|
|
470
471
|
return false
|
|
471
472
|
}
|
|
472
473
|
}
|
|
474
|
+
|
|
475
|
+
async criarBCK(branch: string, sistema: string): Promise<any> {
|
|
476
|
+
await this.jenkinsPost(`${this.jobs.criarbackup}/buildWithParameters`, {
|
|
477
|
+
branch: branch,
|
|
478
|
+
repositorio: sistema,
|
|
479
|
+
});
|
|
480
|
+
await this.sleep(this.buildDelayMs);
|
|
481
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.criarbackup}/api/json`);
|
|
482
|
+
return numbuild.builds[0].number;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async consultarCriarBCK(id: any): Promise<any> {
|
|
486
|
+
try {
|
|
487
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.criarbackup}/${id}/api/json`);
|
|
488
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
489
|
+
if (numbuild.result === "SUCCESS") {
|
|
490
|
+
const consoleText = await this.jenkinsGet(`${this.jobs.criarbackup}/${id}/consoleText`);
|
|
491
|
+
const match = consoleText.match(/([a-zA-Z0-9._-]+_bck_\d{8}_\d{6})/);
|
|
492
|
+
const branch = match ? match[1] : null;
|
|
493
|
+
|
|
494
|
+
return { terminado: true, resultado: true, tipo: "criarbackup", retorno: numbuild.result, parou: branch };
|
|
495
|
+
}
|
|
496
|
+
return { terminado: true, resultado: false, tipo: "criarbackup", retorno: numbuild.result, parou: "" };
|
|
497
|
+
}
|
|
498
|
+
return { terminado: false, resultado: false, tipo: "criarbackup", retorno: numbuild?.result, parou: "" };
|
|
499
|
+
} catch {
|
|
500
|
+
return { terminado: true, resultado: false, tipo: "criarbackup", retorno: "erro interno", parou: "" };
|
|
501
|
+
}
|
|
502
|
+
}
|
|
473
503
|
}
|
|
@@ -62,6 +62,7 @@ var DEFAULT_JOBS = {
|
|
|
62
62
|
publicarDllsNuget: "/job/GCS-AGB-Publicar-dlls-NuGet",
|
|
63
63
|
testeTaVersaoEvolutiva: "/job/QA%20-%20TA%20-%20AGB%20-%20TESTES%20AUTOMATIZADOS%20VERSAO%20EVOLUTIVA%20(GCS)",
|
|
64
64
|
unificarCommits: "/job/GCS-Unificar-commits",
|
|
65
|
+
criarbackup: "job/GCS-CriarBackup"
|
|
65
66
|
};
|
|
66
67
|
function normalizeBaseUrl(url) {
|
|
67
68
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -730,6 +731,53 @@ var BuildnatorClient = /** @class */ (function () {
|
|
|
730
731
|
});
|
|
731
732
|
});
|
|
732
733
|
};
|
|
734
|
+
BuildnatorClient.prototype.criarBCK = function (branch, sistema) {
|
|
735
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
736
|
+
var numbuild;
|
|
737
|
+
return __generator(this, function (_a) {
|
|
738
|
+
switch (_a.label) {
|
|
739
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.criarbackup, "/buildWithParameters"), {
|
|
740
|
+
branch: branch,
|
|
741
|
+
repositorio: sistema,
|
|
742
|
+
})];
|
|
743
|
+
case 1:
|
|
744
|
+
_a.sent();
|
|
745
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
746
|
+
case 2:
|
|
747
|
+
_a.sent();
|
|
748
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.criarbackup, "/api/json"))];
|
|
749
|
+
case 3:
|
|
750
|
+
numbuild = _a.sent();
|
|
751
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
};
|
|
756
|
+
BuildnatorClient.prototype.consultarCriarBCK = function (id) {
|
|
757
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
758
|
+
var numbuild, _a;
|
|
759
|
+
return __generator(this, function (_b) {
|
|
760
|
+
switch (_b.label) {
|
|
761
|
+
case 0:
|
|
762
|
+
_b.trys.push([0, 2, , 3]);
|
|
763
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.criarbackup, "/").concat(id, "/api/json"))];
|
|
764
|
+
case 1:
|
|
765
|
+
numbuild = _b.sent();
|
|
766
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
767
|
+
if (numbuild.result === "SUCCESS") {
|
|
768
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "criarbackup", retorno: numbuild.result }];
|
|
769
|
+
}
|
|
770
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "criarbackup", retorno: numbuild.result }];
|
|
771
|
+
}
|
|
772
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "criarbackup", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
773
|
+
case 2:
|
|
774
|
+
_a = _b.sent();
|
|
775
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "criarbackup", retorno: "erro interno" }];
|
|
776
|
+
case 3: return [2 /*return*/];
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
};
|
|
733
781
|
return BuildnatorClient;
|
|
734
782
|
}());
|
|
735
783
|
exports.BuildnatorClient = BuildnatorClient;
|
package/package.json
CHANGED