buildnator-personal 0.0.2 → 0.0.4

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.
@@ -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 {
@@ -437,4 +438,62 @@ export class BuildnatorClient {
437
438
  return { terminado: true, resultado: false, tipo: "unificar", retorno: "erro interno" };
438
439
  }
439
440
  }
441
+
442
+ async verificarExecucaoLiberaVersao(projeto: any, tipo?: any) {
443
+
444
+ try {
445
+
446
+ if (tipo && tipo === "especifica" && projeto === "agrimanager") {
447
+ const numbuild = await this.jenkinsPost(`${this.jobs.qaAgmLiberaEspecifica}/api/json`);
448
+ const numbuildExecucao = await this.jenkinsPost(`${this.jobs.qaAgmLiberaEspecifica}/${numbuild.builds[0].number}/api/json`);
449
+ if (numbuildExecucao && numbuildExecucao.inProgress === false) {
450
+ return false;
451
+ }
452
+ return true;
453
+ } else {
454
+ if (projeto === "agrimanager") {
455
+ const numbuild = await this.jenkinsPost(`${this.jobs.qaAgmLibera}/api/json`);
456
+ const numbuildExecucao = await this.jenkinsPost(`${this.jobs.qaAgmLibera}/${numbuild.builds[0].number}/api/json`);
457
+ if (numbuildExecucao && numbuildExecucao.inProgress === false) {
458
+ return false;
459
+ }
460
+ return true;
461
+ } else {
462
+ const numbuild = await this.jenkinsPost(`${this.jobs.qaTaAgbLibera}/api/json`);
463
+ const numbuildExecucao = await this.jenkinsPost(`${this.jobs.qaTaAgbLibera}/${numbuild.builds[0].number}/api/json`);
464
+ if (numbuildExecucao && numbuildExecucao.inProgress === false) {
465
+ return false;
466
+ }
467
+ return true;
468
+ }
469
+ }
470
+ } catch {
471
+ return false
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
+ return { terminado: true, resultado: true, tipo: "criarbackup", retorno: numbuild.result };
491
+ }
492
+ return { terminado: true, resultado: false, tipo: "criarbackup", retorno: numbuild.result };
493
+ }
494
+ return { terminado: false, resultado: false, tipo: "criarbackup", retorno: numbuild?.result };
495
+ } catch {
496
+ return { terminado: true, resultado: false, tipo: "criarbackup", retorno: "erro interno" };
497
+ }
498
+ }
440
499
  }
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
@@ -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;
@@ -681,6 +682,102 @@ var BuildnatorClient = /** @class */ (function () {
681
682
  });
682
683
  });
683
684
  };
685
+ BuildnatorClient.prototype.verificarExecucaoLiberaVersao = function (projeto, tipo) {
686
+ return __awaiter(this, void 0, void 0, function () {
687
+ var numbuild, numbuildExecucao, numbuild, numbuildExecucao, numbuild, numbuildExecucao, _a;
688
+ return __generator(this, function (_b) {
689
+ switch (_b.label) {
690
+ case 0:
691
+ _b.trys.push([0, 10, , 11]);
692
+ if (!(tipo && tipo === "especifica" && projeto === "agrimanager")) return [3 /*break*/, 3];
693
+ return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLiberaEspecifica, "/api/json"))];
694
+ case 1:
695
+ numbuild = _b.sent();
696
+ return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLiberaEspecifica, "/").concat(numbuild.builds[0].number, "/api/json"))];
697
+ case 2:
698
+ numbuildExecucao = _b.sent();
699
+ if (numbuildExecucao && numbuildExecucao.inProgress === false) {
700
+ return [2 /*return*/, false];
701
+ }
702
+ return [2 /*return*/, true];
703
+ case 3:
704
+ if (!(projeto === "agrimanager")) return [3 /*break*/, 6];
705
+ return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLibera, "/api/json"))];
706
+ case 4:
707
+ numbuild = _b.sent();
708
+ return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLibera, "/").concat(numbuild.builds[0].number, "/api/json"))];
709
+ case 5:
710
+ numbuildExecucao = _b.sent();
711
+ if (numbuildExecucao && numbuildExecucao.inProgress === false) {
712
+ return [2 /*return*/, false];
713
+ }
714
+ return [2 /*return*/, true];
715
+ case 6: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLibera, "/api/json"))];
716
+ case 7:
717
+ numbuild = _b.sent();
718
+ return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLibera, "/").concat(numbuild.builds[0].number, "/api/json"))];
719
+ case 8:
720
+ numbuildExecucao = _b.sent();
721
+ if (numbuildExecucao && numbuildExecucao.inProgress === false) {
722
+ return [2 /*return*/, false];
723
+ }
724
+ return [2 /*return*/, true];
725
+ case 9: return [3 /*break*/, 11];
726
+ case 10:
727
+ _a = _b.sent();
728
+ return [2 /*return*/, false];
729
+ case 11: return [2 /*return*/];
730
+ }
731
+ });
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
+ };
684
781
  return BuildnatorClient;
685
782
  }());
686
783
  exports.BuildnatorClient = BuildnatorClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buildnator-personal",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Biblioteca cliente para Jenkins do Buildnator",
5
5
  "author": "Victor Rafael",
6
6
  "license": "VR",
package/types.ts CHANGED
@@ -9,6 +9,7 @@ export type JobsConfig = {
9
9
  publicarDllsNuget: string;
10
10
  testeTaVersaoEvolutiva: string;
11
11
  unificarCommits: string;
12
+ criarbackup: string
12
13
  };
13
14
 
14
15
  export type BuildnatorConfig = {