buildnator-personal 0.0.1
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/README.md +93 -0
- package/buildnator.client.ts +440 -0
- package/dist/buildnator.client.js +686 -0
- package/dist/index.js +5 -0
- package/dist/types.js +2 -0
- package/index.ts +2 -0
- package/package.json +25 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +13 -0
- package/types.ts +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# buildnator-personal
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://git.aliare.co/gcs/automacao/buildnator-personal.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](https://git.aliare.co/gcs/automacao/buildnator-personal/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from "axios";
|
|
2
|
+
import * as https from "https";
|
|
3
|
+
import type { BuildnatorConfig, JobsConfig, QueryValue } from "./types";
|
|
4
|
+
|
|
5
|
+
const DEFAULT_BUILD_DELAY_MS = 15000;
|
|
6
|
+
|
|
7
|
+
const DEFAULT_JOBS: JobsConfig = {
|
|
8
|
+
agmCompila: "/job/GCS-AGM-Compila%C3%A7%C3%A3o-Automatizada",
|
|
9
|
+
agbCompila: "/job/GCS-AGB-Compila%C3%A7%C3%A3o-Automatizada",
|
|
10
|
+
agbCompilaVersao: "/job/GCS-AGB-Compilacao-versao-automatizada",
|
|
11
|
+
qaAgmLibera: "/job/QA%20-%20AGM%20-%20Libera%20Vers%C3%A3o",
|
|
12
|
+
qaTaAgbLibera: "/job/QA%20-%20TA%20-%20AGB%20-%20LIBERA%20VERSAO",
|
|
13
|
+
qaAgmLiberaEspecifica: "/job/QA%20-%20AGM%20-%20Libera%20Vers%C3%A3o%20Espec%C3%ADfica",
|
|
14
|
+
qaTaAgbLiberaEspecifica: "/job/QA%20-%20TA%20-%20AGB%20-%20LIBERA%20VERSAO",
|
|
15
|
+
publicarDllsNuget: "/job/GCS-AGB-Publicar-dlls-NuGet",
|
|
16
|
+
testeTaVersaoEvolutiva: "/job/QA%20-%20TA%20-%20AGB%20-%20TESTES%20AUTOMATIZADOS%20VERSAO%20EVOLUTIVA%20(GCS)",
|
|
17
|
+
unificarCommits: "/job/GCS-Unificar-commits",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function normalizeBaseUrl(url: string): string {
|
|
21
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class BuildnatorClient {
|
|
25
|
+
private readonly jenkins: AxiosInstance;
|
|
26
|
+
private readonly auth: { username: string; password: string };
|
|
27
|
+
private readonly jobs: JobsConfig;
|
|
28
|
+
private readonly buildDelayMs: number;
|
|
29
|
+
|
|
30
|
+
constructor(private readonly config: BuildnatorConfig) {
|
|
31
|
+
if (!config?.jenkins?.baseUrl || !config.jenkins.user || !config.jenkins.token) {
|
|
32
|
+
throw new Error("BuildnatorClient: jenkins.baseUrl, jenkins.user e jenkins.token sao obrigatorios.");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const httpsAgent =
|
|
36
|
+
config.tls?.rejectUnauthorized === false
|
|
37
|
+
? new https.Agent({ rejectUnauthorized: false })
|
|
38
|
+
: undefined;
|
|
39
|
+
|
|
40
|
+
this.auth = { username: config.jenkins.user, password: config.jenkins.token };
|
|
41
|
+
|
|
42
|
+
this.jenkins = axios.create({
|
|
43
|
+
baseURL: normalizeBaseUrl(config.jenkins.baseUrl),
|
|
44
|
+
httpsAgent,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/*if (config.gateway?.baseUrl) {
|
|
48
|
+
this.gateway = axios.create({
|
|
49
|
+
baseURL: normalizeBaseUrl(config.gateway.baseUrl),
|
|
50
|
+
httpsAgent,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
this.gateway.interceptors.request.use((req) => {
|
|
54
|
+
const token = config.gateway?.restrictToken;
|
|
55
|
+
if (token) {
|
|
56
|
+
const url = new URL(req.url ?? "", req.baseURL);
|
|
57
|
+
url.searchParams.append("token", token);
|
|
58
|
+
req.url = url.toString();
|
|
59
|
+
}
|
|
60
|
+
return req;
|
|
61
|
+
});
|
|
62
|
+
}*/
|
|
63
|
+
|
|
64
|
+
this.jobs = { ...DEFAULT_JOBS, ...(config.jobs ?? {}) };
|
|
65
|
+
this.buildDelayMs = config.delays?.buildTriggerMs ?? DEFAULT_BUILD_DELAY_MS;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private sleep(ms: number): Promise<void> {
|
|
69
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private async jenkinsPost(path: string, params?: Record<string, QueryValue>) {
|
|
73
|
+
const res = await this.jenkins.post(path, null, { auth: this.auth, params });
|
|
74
|
+
return res.data;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private async jenkinsGet(path: string, params?: Record<string, QueryValue>) {
|
|
78
|
+
const res = await this.jenkins.get(path, { auth: this.auth, params });
|
|
79
|
+
return res.data;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private async jenkinsGetText(path: string, params?: Record<string, QueryValue>) {
|
|
83
|
+
const res = await this.jenkins.get(path, {
|
|
84
|
+
auth: this.auth,
|
|
85
|
+
params,
|
|
86
|
+
responseType: "text",
|
|
87
|
+
});
|
|
88
|
+
return res.data as string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async compilaAGM(branch: string, dirPrefix: string, diretivas: string, version: string): Promise<any> {
|
|
92
|
+
await this.jenkinsPost(`${this.jobs.agmCompila}/buildWithParameters`, {
|
|
93
|
+
branch,
|
|
94
|
+
dirPrefix,
|
|
95
|
+
diretivas,
|
|
96
|
+
version,
|
|
97
|
+
});
|
|
98
|
+
await this.sleep(this.buildDelayMs);
|
|
99
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agmCompila}/api/json`);
|
|
100
|
+
return numbuild.builds[0].number;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async consultaJenkinsAGM(id: number): Promise<any> {
|
|
104
|
+
try {
|
|
105
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agmCompila}/${id}/api/json`);
|
|
106
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
107
|
+
if (numbuild.result === "SUCCESS") {
|
|
108
|
+
return { terminado: true, resultado: true, tipo: "Compila", retorno: numbuild.result };
|
|
109
|
+
}
|
|
110
|
+
return { terminado: true, resultado: false, tipo: "Compila", retorno: numbuild.result };
|
|
111
|
+
}
|
|
112
|
+
return { terminado: false, resultado: false, tipo: "Compila", retorno: numbuild?.result };
|
|
113
|
+
} catch {
|
|
114
|
+
return { terminado: true, resultado: false, tipo: "Compila", retorno: "erro interno" };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async compilaAGB(
|
|
119
|
+
branch: string,
|
|
120
|
+
dirPrefix: string,
|
|
121
|
+
diretivas: string,
|
|
122
|
+
version: string,
|
|
123
|
+
modulos: string,
|
|
124
|
+
gerarVersao: boolean,
|
|
125
|
+
): Promise<any> {
|
|
126
|
+
await this.jenkinsPost(`${this.jobs.agbCompila}/buildWithParameters`, {
|
|
127
|
+
branch,
|
|
128
|
+
dirPrefix,
|
|
129
|
+
diretivas,
|
|
130
|
+
version,
|
|
131
|
+
modulosOpcionais: modulos,
|
|
132
|
+
gerarVersao,
|
|
133
|
+
});
|
|
134
|
+
await this.sleep(this.buildDelayMs);
|
|
135
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agbCompila}/api/json`);
|
|
136
|
+
return numbuild.builds[0].number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async consultaJenkinsAGB(id: number): Promise<any> {
|
|
140
|
+
try {
|
|
141
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agbCompila}/${id}/api/json`);
|
|
142
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
143
|
+
if (numbuild.result === "SUCCESS") {
|
|
144
|
+
return { terminado: true, resultado: true, tipo: "Compila", retorno: numbuild.result };
|
|
145
|
+
}
|
|
146
|
+
return { terminado: true, resultado: false, tipo: "Compila", retorno: numbuild.result };
|
|
147
|
+
}
|
|
148
|
+
return { terminado: false, resultado: false, tipo: "Compila", retorno: numbuild?.result };
|
|
149
|
+
} catch {
|
|
150
|
+
return { terminado: true, resultado: false, tipo: "Compila", retorno: "erro interno" };
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async compilaVersaoAGB(
|
|
155
|
+
branch: string,
|
|
156
|
+
dirPrefix: string,
|
|
157
|
+
diretivas: string,
|
|
158
|
+
version: string,
|
|
159
|
+
modulos: string,
|
|
160
|
+
gerarVersao: boolean,
|
|
161
|
+
alterarDTHR: boolean,
|
|
162
|
+
versionOld?: string | null,
|
|
163
|
+
datahora?: any
|
|
164
|
+
): Promise<any> {
|
|
165
|
+
if (alterarDTHR) {
|
|
166
|
+
if (!versionOld) {
|
|
167
|
+
throw new Error("versionOld eh obrigatorio quando alterarDTHR=true");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const regexversao = /\d+\.\d+\.\d+\.\d+/;
|
|
171
|
+
const regexLetra = /(?<=\d+\.\d+\.\d+\.\d+)[A-Za-z]/;
|
|
172
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
173
|
+
const regexQuantidadeLEtras = /^(\d+\.\d+\.\d+\.\d+)([A-Za-z]{1,2})?$/;
|
|
174
|
+
|
|
175
|
+
const matchquantidade = version.match(regexQuantidadeLEtras);
|
|
176
|
+
const quantidade = matchquantidade && matchquantidade[2] ? matchquantidade[2].length : 0;
|
|
177
|
+
|
|
178
|
+
const matchletra = version.match(regexLetra);
|
|
179
|
+
const letraPrimaria = matchletra ? matchletra[0] : "";
|
|
180
|
+
|
|
181
|
+
let letraSecondaria = letraPrimaria;
|
|
182
|
+
let somasegundos = 0;
|
|
183
|
+
|
|
184
|
+
if (quantidade >= 2) {
|
|
185
|
+
letraSecondaria = version[version.length - 1].toUpperCase();
|
|
186
|
+
const valorminsegundos = Number(alphabet.indexOf(letraSecondaria) + 1) * 10;
|
|
187
|
+
somasegundos += valorminsegundos > 0 ? valorminsegundos + 10 : 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/*const match = versionOld.match(regexversao);
|
|
191
|
+
const versaoSemLetras = match ? match[0] : versionOld;
|
|
192
|
+
|
|
193
|
+
const datahora: any = await this.gatewayGet(
|
|
194
|
+
`/dirservice/arquivos/obtem/datahora/endereco/agribusiness/${versaoSemLetras}`,
|
|
195
|
+
);*/
|
|
196
|
+
|
|
197
|
+
let valormin = Number(alphabet.indexOf(letraPrimaria) + 1) * 5;
|
|
198
|
+
valormin = valormin > 0 ? valormin : 0;
|
|
199
|
+
|
|
200
|
+
let data = "";
|
|
201
|
+
let horaemmin = 1200 + valormin;
|
|
202
|
+
const acrecimomin = ~~((somasegundos / 60) % 60);
|
|
203
|
+
somasegundos = somasegundos % 60;
|
|
204
|
+
|
|
205
|
+
horaemmin += acrecimomin;
|
|
206
|
+
|
|
207
|
+
const min = horaemmin % 60;
|
|
208
|
+
const hora = (horaemmin / 60) % 24;
|
|
209
|
+
|
|
210
|
+
if (datahora && datahora != -1) {
|
|
211
|
+
data = datahora.data;
|
|
212
|
+
} else {
|
|
213
|
+
throw new Error("erro ao pegar data e hora do repositorio");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const formattedTime = [
|
|
217
|
+
String(Number(hora).toPrecision(2)).padStart(2, "0"),
|
|
218
|
+
String(min).padStart(2, "0"),
|
|
219
|
+
String(somasegundos).padStart(2, "0"),
|
|
220
|
+
].join(":");
|
|
221
|
+
|
|
222
|
+
await this.jenkinsPost(`${this.jobs.agbCompilaVersao}/buildWithParameters`, {
|
|
223
|
+
branch,
|
|
224
|
+
dirPrefix,
|
|
225
|
+
diretivas,
|
|
226
|
+
version,
|
|
227
|
+
modulosOpcionais: modulos,
|
|
228
|
+
gerarVersao,
|
|
229
|
+
hora: formattedTime,
|
|
230
|
+
data,
|
|
231
|
+
});
|
|
232
|
+
} else {
|
|
233
|
+
await this.jenkinsPost(`${this.jobs.agbCompilaVersao}/buildWithParameters`, {
|
|
234
|
+
branch,
|
|
235
|
+
dirPrefix,
|
|
236
|
+
diretivas,
|
|
237
|
+
version,
|
|
238
|
+
modulosOpcionais: modulos,
|
|
239
|
+
gerarVersao,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
await this.sleep(this.buildDelayMs);
|
|
244
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agbCompilaVersao}/api/json`);
|
|
245
|
+
return numbuild.builds[0].number;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async consultaVesaoJenkinsAGB(id: number): Promise<any> {
|
|
249
|
+
try {
|
|
250
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agbCompilaVersao}/${id}/api/json`);
|
|
251
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
252
|
+
if (numbuild.result === "SUCCESS") {
|
|
253
|
+
return { terminado: true, resultado: true, tipo: "Compila", retorno: numbuild.result };
|
|
254
|
+
}
|
|
255
|
+
return { terminado: true, resultado: false, tipo: "Compila", retorno: numbuild.result };
|
|
256
|
+
}
|
|
257
|
+
return { terminado: false, resultado: false, tipo: "Compila", retorno: numbuild?.result };
|
|
258
|
+
} catch {
|
|
259
|
+
return { terminado: true, resultado: false, tipo: "Compila", retorno: "erro interno" };
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async consultaConsoleVesaoJenkinsAGB(id: number): Promise<any> {
|
|
264
|
+
const buildInfo = await this.jenkinsPost(`${this.jobs.agbCompilaVersao}/${id}/api/json`);
|
|
265
|
+
const log = await this.jenkinsGetText(`${this.jobs.agbCompilaVersao}/${id}/consoleText`);
|
|
266
|
+
|
|
267
|
+
const parametros: Record<string, any> = {};
|
|
268
|
+
const action = (buildInfo.actions || []).find((a: any) => a && a.parameters);
|
|
269
|
+
if (action?.parameters) {
|
|
270
|
+
action.parameters.forEach((p: any) => {
|
|
271
|
+
parametros[p.name] = p.value;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return { branch: parametros.branch, log };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
async consultaBuildVersoesAGB(): Promise<any> {
|
|
279
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.agbCompilaVersao}/api/json`);
|
|
280
|
+
return numbuild.builds;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async liberaAGM(diretorio: string, baseline: string): Promise<any> {
|
|
284
|
+
await this.jenkinsPost(`${this.jobs.qaAgmLibera}/buildWithParameters`, {
|
|
285
|
+
diretorioExecutaveis: diretorio,
|
|
286
|
+
baselineExecutaveis: baseline,
|
|
287
|
+
});
|
|
288
|
+
await this.sleep(this.buildDelayMs);
|
|
289
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.qaAgmLibera}/api/json`);
|
|
290
|
+
return numbuild.builds[0].number;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
async liberaAGB(diretorio: string, baseline: string): Promise<any> {
|
|
294
|
+
await this.jenkinsPost(`${this.jobs.qaTaAgbLibera}/buildWithParameters`, {
|
|
295
|
+
diretorioExecutaveis: diretorio,
|
|
296
|
+
baselineExecutaveis: baseline,
|
|
297
|
+
});
|
|
298
|
+
await this.sleep(this.buildDelayMs);
|
|
299
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.qaTaAgbLibera}/api/json`);
|
|
300
|
+
return numbuild.builds[0].number;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
async liberaAGMEspecifica(diretorio: string, baseline: string): Promise<any> {
|
|
304
|
+
await this.jenkinsPost(`${this.jobs.qaAgmLiberaEspecifica}/buildWithParameters`, {
|
|
305
|
+
diretorioExecutaveis: diretorio,
|
|
306
|
+
baselineExecutaveis: baseline,
|
|
307
|
+
});
|
|
308
|
+
await this.sleep(this.buildDelayMs);
|
|
309
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.qaAgmLiberaEspecifica}/api/json`);
|
|
310
|
+
return numbuild.builds[0].number;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async liberaAGBEspecifica(diretorio: string, baseline: string): Promise<any> {
|
|
314
|
+
await this.jenkinsPost(`${this.jobs.qaTaAgbLiberaEspecifica}/buildWithParameters`, {
|
|
315
|
+
diretorioExecutaveis: diretorio,
|
|
316
|
+
baseline,
|
|
317
|
+
});
|
|
318
|
+
await this.sleep(this.buildDelayMs);
|
|
319
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.qaTaAgbLiberaEspecifica}/api/json`);
|
|
320
|
+
return numbuild.builds[0].number;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async consultaLiberaEspecifica(id: number, projeto: string): Promise<any> {
|
|
324
|
+
try {
|
|
325
|
+
let numbuild: any;
|
|
326
|
+
if (projeto === "agribusiness") {
|
|
327
|
+
numbuild = await this.jenkinsPost(`${this.jobs.qaTaAgbLibera}/${id}/api/json`);
|
|
328
|
+
} else {
|
|
329
|
+
numbuild = await this.jenkinsPost(`${this.jobs.qaAgmLiberaEspecifica}/${id}/api/json`);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
333
|
+
if (numbuild.result === "SUCCESS") {
|
|
334
|
+
return { terminado: true, resultado: true, tipo: "Libera", retorno: numbuild.result };
|
|
335
|
+
}
|
|
336
|
+
return { terminado: true, resultado: false, tipo: "Libera", retorno: numbuild.result };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return { terminado: false, resultado: false, tipo: "Libera", retorno: numbuild?.result };
|
|
340
|
+
} catch {
|
|
341
|
+
return { terminado: true, resultado: false, tipo: "Libera", retorno: "erro interno" };
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async consultaLibera(id: number, projeto: string): Promise<any> {
|
|
346
|
+
try {
|
|
347
|
+
let numbuild: any;
|
|
348
|
+
if (projeto === "agribusiness") {
|
|
349
|
+
numbuild = await this.jenkinsPost(`${this.jobs.qaTaAgbLibera}/${id}/api/json`);
|
|
350
|
+
} else {
|
|
351
|
+
numbuild = await this.jenkinsPost(`${this.jobs.qaAgmLibera}/${id}/api/json`);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
355
|
+
if (numbuild.result === "SUCCESS") {
|
|
356
|
+
return { terminado: true, resultado: true, tipo: "Libera", retorno: numbuild.result };
|
|
357
|
+
}
|
|
358
|
+
return { terminado: true, resultado: false, tipo: "Libera", retorno: numbuild.result };
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
return { terminado: false, resultado: false, tipo: "Libera", retorno: numbuild?.result };
|
|
362
|
+
} catch {
|
|
363
|
+
return { terminado: true, resultado: false, tipo: "Libera", retorno: "erro interno" };
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
async PublicarDllsNuGet(versao: string, dirPrefix: string): Promise<any> {
|
|
368
|
+
await this.jenkinsPost(`${this.jobs.publicarDllsNuget}/buildWithParameters`, {
|
|
369
|
+
version: versao,
|
|
370
|
+
diretoriobaseversao: dirPrefix,
|
|
371
|
+
});
|
|
372
|
+
await this.sleep(this.buildDelayMs);
|
|
373
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.publicarDllsNuget}/api/json`);
|
|
374
|
+
return numbuild.builds[0].number;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
async consultaPublicarDllsNuGet(id: number): Promise<any> {
|
|
378
|
+
try {
|
|
379
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.publicarDllsNuget}/${id}/api/json`);
|
|
380
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
381
|
+
if (numbuild.result === "SUCCESS") {
|
|
382
|
+
return { terminado: true, resultado: true, tipo: "publicar", retorno: numbuild.result };
|
|
383
|
+
}
|
|
384
|
+
return { terminado: true, resultado: false, tipo: "publicar", retorno: numbuild.result };
|
|
385
|
+
}
|
|
386
|
+
return { terminado: false, resultado: false, tipo: "publicar", retorno: numbuild?.result };
|
|
387
|
+
} catch {
|
|
388
|
+
return { terminado: true, resultado: false, tipo: "publicar", retorno: "erro interno" };
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async testeTaVersaoEvolutiva(diretorioExecutaveis: string): Promise<any> {
|
|
393
|
+
await this.jenkinsPost(`${this.jobs.testeTaVersaoEvolutiva}/buildWithParameters`, {
|
|
394
|
+
diretorioExecutaveis,
|
|
395
|
+
});
|
|
396
|
+
await this.sleep(this.buildDelayMs);
|
|
397
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.testeTaVersaoEvolutiva}/api/json`);
|
|
398
|
+
return numbuild.builds[0].number;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
async consultatesteTaVersaoEvolutiva(id: any): Promise<any> {
|
|
402
|
+
try {
|
|
403
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.testeTaVersaoEvolutiva}/${id}/api/json`);
|
|
404
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
405
|
+
if (numbuild.result === "SUCCESS") {
|
|
406
|
+
return { terminado: true, resultado: true, tipo: "testeTa", retorno: numbuild.result };
|
|
407
|
+
}
|
|
408
|
+
return { terminado: true, resultado: false, tipo: "testeTa", retorno: numbuild.result };
|
|
409
|
+
}
|
|
410
|
+
return { terminado: false, resultado: false, tipo: "testeTa", retorno: numbuild?.result };
|
|
411
|
+
} catch {
|
|
412
|
+
return { terminado: true, resultado: false, tipo: "testeTa", retorno: "erro interno" };
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
async unificarCommits(branch: string, sistema: string): Promise<any> {
|
|
417
|
+
await this.jenkinsPost(`${this.jobs.unificarCommits}/buildWithParameters`, {
|
|
418
|
+
Branch: branch,
|
|
419
|
+
repositorio: sistema,
|
|
420
|
+
});
|
|
421
|
+
await this.sleep(this.buildDelayMs);
|
|
422
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.unificarCommits}/api/json`);
|
|
423
|
+
return numbuild.builds[0].number;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
async consultarUnificarCommits(id: any): Promise<any> {
|
|
427
|
+
try {
|
|
428
|
+
const numbuild = await this.jenkinsPost(`${this.jobs.unificarCommits}/${id}/api/json`);
|
|
429
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
430
|
+
if (numbuild.result === "SUCCESS") {
|
|
431
|
+
return { terminado: true, resultado: true, tipo: "unificar", retorno: numbuild.result };
|
|
432
|
+
}
|
|
433
|
+
return { terminado: true, resultado: false, tipo: "unificar", retorno: numbuild.result };
|
|
434
|
+
}
|
|
435
|
+
return { terminado: false, resultado: false, tipo: "unificar", retorno: numbuild?.result };
|
|
436
|
+
} catch {
|
|
437
|
+
return { terminado: true, resultado: false, tipo: "unificar", retorno: "erro interno" };
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
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 = 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
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.BuildnatorClient = void 0;
|
|
51
|
+
var axios_1 = require("axios");
|
|
52
|
+
var https = require("https");
|
|
53
|
+
var DEFAULT_BUILD_DELAY_MS = 15000;
|
|
54
|
+
var DEFAULT_JOBS = {
|
|
55
|
+
agmCompila: "/job/GCS-AGM-Compila%C3%A7%C3%A3o-Automatizada",
|
|
56
|
+
agbCompila: "/job/GCS-AGB-Compila%C3%A7%C3%A3o-Automatizada",
|
|
57
|
+
agbCompilaVersao: "/job/GCS-AGB-Compilacao-versao-automatizada",
|
|
58
|
+
qaAgmLibera: "/job/QA%20-%20AGM%20-%20Libera%20Vers%C3%A3o",
|
|
59
|
+
qaTaAgbLibera: "/job/QA%20-%20TA%20-%20AGB%20-%20LIBERA%20VERSAO",
|
|
60
|
+
qaAgmLiberaEspecifica: "/job/QA%20-%20AGM%20-%20Libera%20Vers%C3%A3o%20Espec%C3%ADfica",
|
|
61
|
+
qaTaAgbLiberaEspecifica: "/job/QA%20-%20TA%20-%20AGB%20-%20LIBERA%20VERSAO",
|
|
62
|
+
publicarDllsNuget: "/job/GCS-AGB-Publicar-dlls-NuGet",
|
|
63
|
+
testeTaVersaoEvolutiva: "/job/QA%20-%20TA%20-%20AGB%20-%20TESTES%20AUTOMATIZADOS%20VERSAO%20EVOLUTIVA%20(GCS)",
|
|
64
|
+
unificarCommits: "/job/GCS-Unificar-commits",
|
|
65
|
+
};
|
|
66
|
+
function normalizeBaseUrl(url) {
|
|
67
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
68
|
+
}
|
|
69
|
+
var BuildnatorClient = /** @class */ (function () {
|
|
70
|
+
function BuildnatorClient(config) {
|
|
71
|
+
var _a, _b, _c, _d, _e;
|
|
72
|
+
this.config = config;
|
|
73
|
+
if (!((_a = config === null || config === void 0 ? void 0 : config.jenkins) === null || _a === void 0 ? void 0 : _a.baseUrl) || !config.jenkins.user || !config.jenkins.token) {
|
|
74
|
+
throw new Error("BuildnatorClient: jenkins.baseUrl, jenkins.user e jenkins.token sao obrigatorios.");
|
|
75
|
+
}
|
|
76
|
+
var httpsAgent = ((_b = config.tls) === null || _b === void 0 ? void 0 : _b.rejectUnauthorized) === false
|
|
77
|
+
? new https.Agent({ rejectUnauthorized: false })
|
|
78
|
+
: undefined;
|
|
79
|
+
this.auth = { username: config.jenkins.user, password: config.jenkins.token };
|
|
80
|
+
this.jenkins = axios_1.default.create({
|
|
81
|
+
baseURL: normalizeBaseUrl(config.jenkins.baseUrl),
|
|
82
|
+
httpsAgent: httpsAgent,
|
|
83
|
+
});
|
|
84
|
+
/*if (config.gateway?.baseUrl) {
|
|
85
|
+
this.gateway = axios.create({
|
|
86
|
+
baseURL: normalizeBaseUrl(config.gateway.baseUrl),
|
|
87
|
+
httpsAgent,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this.gateway.interceptors.request.use((req) => {
|
|
91
|
+
const token = config.gateway?.restrictToken;
|
|
92
|
+
if (token) {
|
|
93
|
+
const url = new URL(req.url ?? "", req.baseURL);
|
|
94
|
+
url.searchParams.append("token", token);
|
|
95
|
+
req.url = url.toString();
|
|
96
|
+
}
|
|
97
|
+
return req;
|
|
98
|
+
});
|
|
99
|
+
}*/
|
|
100
|
+
this.jobs = __assign(__assign({}, DEFAULT_JOBS), ((_c = config.jobs) !== null && _c !== void 0 ? _c : {}));
|
|
101
|
+
this.buildDelayMs = (_e = (_d = config.delays) === null || _d === void 0 ? void 0 : _d.buildTriggerMs) !== null && _e !== void 0 ? _e : DEFAULT_BUILD_DELAY_MS;
|
|
102
|
+
}
|
|
103
|
+
BuildnatorClient.prototype.sleep = function (ms) {
|
|
104
|
+
return new Promise(function (resolve) { return setTimeout(resolve, ms); });
|
|
105
|
+
};
|
|
106
|
+
BuildnatorClient.prototype.jenkinsPost = function (path, params) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
+
var res;
|
|
109
|
+
return __generator(this, function (_a) {
|
|
110
|
+
switch (_a.label) {
|
|
111
|
+
case 0: return [4 /*yield*/, this.jenkins.post(path, null, { auth: this.auth, params: params })];
|
|
112
|
+
case 1:
|
|
113
|
+
res = _a.sent();
|
|
114
|
+
return [2 /*return*/, res.data];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
BuildnatorClient.prototype.jenkinsGet = function (path, params) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
+
var res;
|
|
122
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0: return [4 /*yield*/, this.jenkins.get(path, { auth: this.auth, params: params })];
|
|
125
|
+
case 1:
|
|
126
|
+
res = _a.sent();
|
|
127
|
+
return [2 /*return*/, res.data];
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
BuildnatorClient.prototype.jenkinsGetText = function (path, params) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
var res;
|
|
135
|
+
return __generator(this, function (_a) {
|
|
136
|
+
switch (_a.label) {
|
|
137
|
+
case 0: return [4 /*yield*/, this.jenkins.get(path, {
|
|
138
|
+
auth: this.auth,
|
|
139
|
+
params: params,
|
|
140
|
+
responseType: "text",
|
|
141
|
+
})];
|
|
142
|
+
case 1:
|
|
143
|
+
res = _a.sent();
|
|
144
|
+
return [2 /*return*/, res.data];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
BuildnatorClient.prototype.compilaAGM = function (branch, dirPrefix, diretivas, version) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
var numbuild;
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (_a.label) {
|
|
154
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agmCompila, "/buildWithParameters"), {
|
|
155
|
+
branch: branch,
|
|
156
|
+
dirPrefix: dirPrefix,
|
|
157
|
+
diretivas: diretivas,
|
|
158
|
+
version: version,
|
|
159
|
+
})];
|
|
160
|
+
case 1:
|
|
161
|
+
_a.sent();
|
|
162
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
163
|
+
case 2:
|
|
164
|
+
_a.sent();
|
|
165
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agmCompila, "/api/json"))];
|
|
166
|
+
case 3:
|
|
167
|
+
numbuild = _a.sent();
|
|
168
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
BuildnatorClient.prototype.consultaJenkinsAGM = function (id) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var numbuild, _a;
|
|
176
|
+
return __generator(this, function (_b) {
|
|
177
|
+
switch (_b.label) {
|
|
178
|
+
case 0:
|
|
179
|
+
_b.trys.push([0, 2, , 3]);
|
|
180
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agmCompila, "/").concat(id, "/api/json"))];
|
|
181
|
+
case 1:
|
|
182
|
+
numbuild = _b.sent();
|
|
183
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
184
|
+
if (numbuild.result === "SUCCESS") {
|
|
185
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "Compila", retorno: numbuild.result }];
|
|
186
|
+
}
|
|
187
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Compila", retorno: numbuild.result }];
|
|
188
|
+
}
|
|
189
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "Compila", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
190
|
+
case 2:
|
|
191
|
+
_a = _b.sent();
|
|
192
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Compila", retorno: "erro interno" }];
|
|
193
|
+
case 3: return [2 /*return*/];
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
BuildnatorClient.prototype.compilaAGB = function (branch, dirPrefix, diretivas, version, modulos, gerarVersao) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
+
var numbuild;
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
switch (_a.label) {
|
|
203
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompila, "/buildWithParameters"), {
|
|
204
|
+
branch: branch,
|
|
205
|
+
dirPrefix: dirPrefix,
|
|
206
|
+
diretivas: diretivas,
|
|
207
|
+
version: version,
|
|
208
|
+
modulosOpcionais: modulos,
|
|
209
|
+
gerarVersao: gerarVersao,
|
|
210
|
+
})];
|
|
211
|
+
case 1:
|
|
212
|
+
_a.sent();
|
|
213
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
214
|
+
case 2:
|
|
215
|
+
_a.sent();
|
|
216
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompila, "/api/json"))];
|
|
217
|
+
case 3:
|
|
218
|
+
numbuild = _a.sent();
|
|
219
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
BuildnatorClient.prototype.consultaJenkinsAGB = function (id) {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
226
|
+
var numbuild, _a;
|
|
227
|
+
return __generator(this, function (_b) {
|
|
228
|
+
switch (_b.label) {
|
|
229
|
+
case 0:
|
|
230
|
+
_b.trys.push([0, 2, , 3]);
|
|
231
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompila, "/").concat(id, "/api/json"))];
|
|
232
|
+
case 1:
|
|
233
|
+
numbuild = _b.sent();
|
|
234
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
235
|
+
if (numbuild.result === "SUCCESS") {
|
|
236
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "Compila", retorno: numbuild.result }];
|
|
237
|
+
}
|
|
238
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Compila", retorno: numbuild.result }];
|
|
239
|
+
}
|
|
240
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "Compila", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
241
|
+
case 2:
|
|
242
|
+
_a = _b.sent();
|
|
243
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Compila", retorno: "erro interno" }];
|
|
244
|
+
case 3: return [2 /*return*/];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
BuildnatorClient.prototype.compilaVersaoAGB = function (branch, dirPrefix, diretivas, version, modulos, gerarVersao, alterarDTHR, versionOld, datahora) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
251
|
+
var regexversao, regexLetra, alphabet, regexQuantidadeLEtras, matchquantidade, quantidade, matchletra, letraPrimaria, letraSecondaria, somasegundos, valorminsegundos, valormin, data, horaemmin, acrecimomin, min, hora, formattedTime, numbuild;
|
|
252
|
+
return __generator(this, function (_a) {
|
|
253
|
+
switch (_a.label) {
|
|
254
|
+
case 0:
|
|
255
|
+
if (!alterarDTHR) return [3 /*break*/, 2];
|
|
256
|
+
if (!versionOld) {
|
|
257
|
+
throw new Error("versionOld eh obrigatorio quando alterarDTHR=true");
|
|
258
|
+
}
|
|
259
|
+
regexversao = /\d+\.\d+\.\d+\.\d+/;
|
|
260
|
+
regexLetra = /(?<=\d+\.\d+\.\d+\.\d+)[A-Za-z]/;
|
|
261
|
+
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
262
|
+
regexQuantidadeLEtras = /^(\d+\.\d+\.\d+\.\d+)([A-Za-z]{1,2})?$/;
|
|
263
|
+
matchquantidade = version.match(regexQuantidadeLEtras);
|
|
264
|
+
quantidade = matchquantidade && matchquantidade[2] ? matchquantidade[2].length : 0;
|
|
265
|
+
matchletra = version.match(regexLetra);
|
|
266
|
+
letraPrimaria = matchletra ? matchletra[0] : "";
|
|
267
|
+
letraSecondaria = letraPrimaria;
|
|
268
|
+
somasegundos = 0;
|
|
269
|
+
if (quantidade >= 2) {
|
|
270
|
+
letraSecondaria = version[version.length - 1].toUpperCase();
|
|
271
|
+
valorminsegundos = Number(alphabet.indexOf(letraSecondaria) + 1) * 10;
|
|
272
|
+
somasegundos += valorminsegundos > 0 ? valorminsegundos + 10 : 0;
|
|
273
|
+
}
|
|
274
|
+
valormin = Number(alphabet.indexOf(letraPrimaria) + 1) * 5;
|
|
275
|
+
valormin = valormin > 0 ? valormin : 0;
|
|
276
|
+
data = "";
|
|
277
|
+
horaemmin = 1200 + valormin;
|
|
278
|
+
acrecimomin = ~~((somasegundos / 60) % 60);
|
|
279
|
+
somasegundos = somasegundos % 60;
|
|
280
|
+
horaemmin += acrecimomin;
|
|
281
|
+
min = horaemmin % 60;
|
|
282
|
+
hora = (horaemmin / 60) % 24;
|
|
283
|
+
if (datahora && datahora != -1) {
|
|
284
|
+
data = datahora.data;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
throw new Error("erro ao pegar data e hora do repositorio");
|
|
288
|
+
}
|
|
289
|
+
formattedTime = [
|
|
290
|
+
String(Number(hora).toPrecision(2)).padStart(2, "0"),
|
|
291
|
+
String(min).padStart(2, "0"),
|
|
292
|
+
String(somasegundos).padStart(2, "0"),
|
|
293
|
+
].join(":");
|
|
294
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompilaVersao, "/buildWithParameters"), {
|
|
295
|
+
branch: branch,
|
|
296
|
+
dirPrefix: dirPrefix,
|
|
297
|
+
diretivas: diretivas,
|
|
298
|
+
version: version,
|
|
299
|
+
modulosOpcionais: modulos,
|
|
300
|
+
gerarVersao: gerarVersao,
|
|
301
|
+
hora: formattedTime,
|
|
302
|
+
data: data,
|
|
303
|
+
})];
|
|
304
|
+
case 1:
|
|
305
|
+
_a.sent();
|
|
306
|
+
return [3 /*break*/, 4];
|
|
307
|
+
case 2: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompilaVersao, "/buildWithParameters"), {
|
|
308
|
+
branch: branch,
|
|
309
|
+
dirPrefix: dirPrefix,
|
|
310
|
+
diretivas: diretivas,
|
|
311
|
+
version: version,
|
|
312
|
+
modulosOpcionais: modulos,
|
|
313
|
+
gerarVersao: gerarVersao,
|
|
314
|
+
})];
|
|
315
|
+
case 3:
|
|
316
|
+
_a.sent();
|
|
317
|
+
_a.label = 4;
|
|
318
|
+
case 4: return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
319
|
+
case 5:
|
|
320
|
+
_a.sent();
|
|
321
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompilaVersao, "/api/json"))];
|
|
322
|
+
case 6:
|
|
323
|
+
numbuild = _a.sent();
|
|
324
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
};
|
|
329
|
+
BuildnatorClient.prototype.consultaVesaoJenkinsAGB = function (id) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
331
|
+
var numbuild, _a;
|
|
332
|
+
return __generator(this, function (_b) {
|
|
333
|
+
switch (_b.label) {
|
|
334
|
+
case 0:
|
|
335
|
+
_b.trys.push([0, 2, , 3]);
|
|
336
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompilaVersao, "/").concat(id, "/api/json"))];
|
|
337
|
+
case 1:
|
|
338
|
+
numbuild = _b.sent();
|
|
339
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
340
|
+
if (numbuild.result === "SUCCESS") {
|
|
341
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "Compila", retorno: numbuild.result }];
|
|
342
|
+
}
|
|
343
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Compila", retorno: numbuild.result }];
|
|
344
|
+
}
|
|
345
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "Compila", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
346
|
+
case 2:
|
|
347
|
+
_a = _b.sent();
|
|
348
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Compila", retorno: "erro interno" }];
|
|
349
|
+
case 3: return [2 /*return*/];
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
BuildnatorClient.prototype.consultaConsoleVesaoJenkinsAGB = function (id) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
356
|
+
var buildInfo, log, parametros, action;
|
|
357
|
+
return __generator(this, function (_a) {
|
|
358
|
+
switch (_a.label) {
|
|
359
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompilaVersao, "/").concat(id, "/api/json"))];
|
|
360
|
+
case 1:
|
|
361
|
+
buildInfo = _a.sent();
|
|
362
|
+
return [4 /*yield*/, this.jenkinsGetText("".concat(this.jobs.agbCompilaVersao, "/").concat(id, "/consoleText"))];
|
|
363
|
+
case 2:
|
|
364
|
+
log = _a.sent();
|
|
365
|
+
parametros = {};
|
|
366
|
+
action = (buildInfo.actions || []).find(function (a) { return a && a.parameters; });
|
|
367
|
+
if (action === null || action === void 0 ? void 0 : action.parameters) {
|
|
368
|
+
action.parameters.forEach(function (p) {
|
|
369
|
+
parametros[p.name] = p.value;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return [2 /*return*/, { branch: parametros.branch, log: log }];
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
BuildnatorClient.prototype.consultaBuildVersoesAGB = function () {
|
|
378
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
379
|
+
var numbuild;
|
|
380
|
+
return __generator(this, function (_a) {
|
|
381
|
+
switch (_a.label) {
|
|
382
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.agbCompilaVersao, "/api/json"))];
|
|
383
|
+
case 1:
|
|
384
|
+
numbuild = _a.sent();
|
|
385
|
+
return [2 /*return*/, numbuild.builds];
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
};
|
|
390
|
+
BuildnatorClient.prototype.liberaAGM = function (diretorio, baseline) {
|
|
391
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
392
|
+
var numbuild;
|
|
393
|
+
return __generator(this, function (_a) {
|
|
394
|
+
switch (_a.label) {
|
|
395
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLibera, "/buildWithParameters"), {
|
|
396
|
+
diretorioExecutaveis: diretorio,
|
|
397
|
+
baselineExecutaveis: baseline,
|
|
398
|
+
})];
|
|
399
|
+
case 1:
|
|
400
|
+
_a.sent();
|
|
401
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
402
|
+
case 2:
|
|
403
|
+
_a.sent();
|
|
404
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLibera, "/api/json"))];
|
|
405
|
+
case 3:
|
|
406
|
+
numbuild = _a.sent();
|
|
407
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
BuildnatorClient.prototype.liberaAGB = function (diretorio, baseline) {
|
|
413
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
414
|
+
var numbuild;
|
|
415
|
+
return __generator(this, function (_a) {
|
|
416
|
+
switch (_a.label) {
|
|
417
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLibera, "/buildWithParameters"), {
|
|
418
|
+
diretorioExecutaveis: diretorio,
|
|
419
|
+
baselineExecutaveis: baseline,
|
|
420
|
+
})];
|
|
421
|
+
case 1:
|
|
422
|
+
_a.sent();
|
|
423
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
424
|
+
case 2:
|
|
425
|
+
_a.sent();
|
|
426
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLibera, "/api/json"))];
|
|
427
|
+
case 3:
|
|
428
|
+
numbuild = _a.sent();
|
|
429
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
BuildnatorClient.prototype.liberaAGMEspecifica = function (diretorio, baseline) {
|
|
435
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
436
|
+
var numbuild;
|
|
437
|
+
return __generator(this, function (_a) {
|
|
438
|
+
switch (_a.label) {
|
|
439
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLiberaEspecifica, "/buildWithParameters"), {
|
|
440
|
+
diretorioExecutaveis: diretorio,
|
|
441
|
+
baselineExecutaveis: baseline,
|
|
442
|
+
})];
|
|
443
|
+
case 1:
|
|
444
|
+
_a.sent();
|
|
445
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
446
|
+
case 2:
|
|
447
|
+
_a.sent();
|
|
448
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLiberaEspecifica, "/api/json"))];
|
|
449
|
+
case 3:
|
|
450
|
+
numbuild = _a.sent();
|
|
451
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
};
|
|
456
|
+
BuildnatorClient.prototype.liberaAGBEspecifica = function (diretorio, baseline) {
|
|
457
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
458
|
+
var numbuild;
|
|
459
|
+
return __generator(this, function (_a) {
|
|
460
|
+
switch (_a.label) {
|
|
461
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLiberaEspecifica, "/buildWithParameters"), {
|
|
462
|
+
diretorioExecutaveis: diretorio,
|
|
463
|
+
baseline: baseline,
|
|
464
|
+
})];
|
|
465
|
+
case 1:
|
|
466
|
+
_a.sent();
|
|
467
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
468
|
+
case 2:
|
|
469
|
+
_a.sent();
|
|
470
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLiberaEspecifica, "/api/json"))];
|
|
471
|
+
case 3:
|
|
472
|
+
numbuild = _a.sent();
|
|
473
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
};
|
|
478
|
+
BuildnatorClient.prototype.consultaLiberaEspecifica = function (id, projeto) {
|
|
479
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
480
|
+
var numbuild, _a;
|
|
481
|
+
return __generator(this, function (_b) {
|
|
482
|
+
switch (_b.label) {
|
|
483
|
+
case 0:
|
|
484
|
+
_b.trys.push([0, 5, , 6]);
|
|
485
|
+
numbuild = void 0;
|
|
486
|
+
if (!(projeto === "agribusiness")) return [3 /*break*/, 2];
|
|
487
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLibera, "/").concat(id, "/api/json"))];
|
|
488
|
+
case 1:
|
|
489
|
+
numbuild = _b.sent();
|
|
490
|
+
return [3 /*break*/, 4];
|
|
491
|
+
case 2: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLiberaEspecifica, "/").concat(id, "/api/json"))];
|
|
492
|
+
case 3:
|
|
493
|
+
numbuild = _b.sent();
|
|
494
|
+
_b.label = 4;
|
|
495
|
+
case 4:
|
|
496
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
497
|
+
if (numbuild.result === "SUCCESS") {
|
|
498
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "Libera", retorno: numbuild.result }];
|
|
499
|
+
}
|
|
500
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Libera", retorno: numbuild.result }];
|
|
501
|
+
}
|
|
502
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "Libera", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
503
|
+
case 5:
|
|
504
|
+
_a = _b.sent();
|
|
505
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Libera", retorno: "erro interno" }];
|
|
506
|
+
case 6: return [2 /*return*/];
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
BuildnatorClient.prototype.consultaLibera = function (id, projeto) {
|
|
512
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
513
|
+
var numbuild, _a;
|
|
514
|
+
return __generator(this, function (_b) {
|
|
515
|
+
switch (_b.label) {
|
|
516
|
+
case 0:
|
|
517
|
+
_b.trys.push([0, 5, , 6]);
|
|
518
|
+
numbuild = void 0;
|
|
519
|
+
if (!(projeto === "agribusiness")) return [3 /*break*/, 2];
|
|
520
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaTaAgbLibera, "/").concat(id, "/api/json"))];
|
|
521
|
+
case 1:
|
|
522
|
+
numbuild = _b.sent();
|
|
523
|
+
return [3 /*break*/, 4];
|
|
524
|
+
case 2: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.qaAgmLibera, "/").concat(id, "/api/json"))];
|
|
525
|
+
case 3:
|
|
526
|
+
numbuild = _b.sent();
|
|
527
|
+
_b.label = 4;
|
|
528
|
+
case 4:
|
|
529
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
530
|
+
if (numbuild.result === "SUCCESS") {
|
|
531
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "Libera", retorno: numbuild.result }];
|
|
532
|
+
}
|
|
533
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Libera", retorno: numbuild.result }];
|
|
534
|
+
}
|
|
535
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "Libera", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
536
|
+
case 5:
|
|
537
|
+
_a = _b.sent();
|
|
538
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "Libera", retorno: "erro interno" }];
|
|
539
|
+
case 6: return [2 /*return*/];
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
});
|
|
543
|
+
};
|
|
544
|
+
BuildnatorClient.prototype.PublicarDllsNuGet = function (versao, dirPrefix) {
|
|
545
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
546
|
+
var numbuild;
|
|
547
|
+
return __generator(this, function (_a) {
|
|
548
|
+
switch (_a.label) {
|
|
549
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.publicarDllsNuget, "/buildWithParameters"), {
|
|
550
|
+
version: versao,
|
|
551
|
+
diretoriobaseversao: dirPrefix,
|
|
552
|
+
})];
|
|
553
|
+
case 1:
|
|
554
|
+
_a.sent();
|
|
555
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
556
|
+
case 2:
|
|
557
|
+
_a.sent();
|
|
558
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.publicarDllsNuget, "/api/json"))];
|
|
559
|
+
case 3:
|
|
560
|
+
numbuild = _a.sent();
|
|
561
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
};
|
|
566
|
+
BuildnatorClient.prototype.consultaPublicarDllsNuGet = function (id) {
|
|
567
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
568
|
+
var numbuild, _a;
|
|
569
|
+
return __generator(this, function (_b) {
|
|
570
|
+
switch (_b.label) {
|
|
571
|
+
case 0:
|
|
572
|
+
_b.trys.push([0, 2, , 3]);
|
|
573
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.publicarDllsNuget, "/").concat(id, "/api/json"))];
|
|
574
|
+
case 1:
|
|
575
|
+
numbuild = _b.sent();
|
|
576
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
577
|
+
if (numbuild.result === "SUCCESS") {
|
|
578
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "publicar", retorno: numbuild.result }];
|
|
579
|
+
}
|
|
580
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "publicar", retorno: numbuild.result }];
|
|
581
|
+
}
|
|
582
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "publicar", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
583
|
+
case 2:
|
|
584
|
+
_a = _b.sent();
|
|
585
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "publicar", retorno: "erro interno" }];
|
|
586
|
+
case 3: return [2 /*return*/];
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
BuildnatorClient.prototype.testeTaVersaoEvolutiva = function (diretorioExecutaveis) {
|
|
592
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
593
|
+
var numbuild;
|
|
594
|
+
return __generator(this, function (_a) {
|
|
595
|
+
switch (_a.label) {
|
|
596
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.testeTaVersaoEvolutiva, "/buildWithParameters"), {
|
|
597
|
+
diretorioExecutaveis: diretorioExecutaveis,
|
|
598
|
+
})];
|
|
599
|
+
case 1:
|
|
600
|
+
_a.sent();
|
|
601
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
602
|
+
case 2:
|
|
603
|
+
_a.sent();
|
|
604
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.testeTaVersaoEvolutiva, "/api/json"))];
|
|
605
|
+
case 3:
|
|
606
|
+
numbuild = _a.sent();
|
|
607
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
BuildnatorClient.prototype.consultatesteTaVersaoEvolutiva = function (id) {
|
|
613
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
614
|
+
var numbuild, _a;
|
|
615
|
+
return __generator(this, function (_b) {
|
|
616
|
+
switch (_b.label) {
|
|
617
|
+
case 0:
|
|
618
|
+
_b.trys.push([0, 2, , 3]);
|
|
619
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.testeTaVersaoEvolutiva, "/").concat(id, "/api/json"))];
|
|
620
|
+
case 1:
|
|
621
|
+
numbuild = _b.sent();
|
|
622
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
623
|
+
if (numbuild.result === "SUCCESS") {
|
|
624
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "testeTa", retorno: numbuild.result }];
|
|
625
|
+
}
|
|
626
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "testeTa", retorno: numbuild.result }];
|
|
627
|
+
}
|
|
628
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "testeTa", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
629
|
+
case 2:
|
|
630
|
+
_a = _b.sent();
|
|
631
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "testeTa", retorno: "erro interno" }];
|
|
632
|
+
case 3: return [2 /*return*/];
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
BuildnatorClient.prototype.unificarCommits = function (branch, sistema) {
|
|
638
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
639
|
+
var numbuild;
|
|
640
|
+
return __generator(this, function (_a) {
|
|
641
|
+
switch (_a.label) {
|
|
642
|
+
case 0: return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.unificarCommits, "/buildWithParameters"), {
|
|
643
|
+
Branch: branch,
|
|
644
|
+
repositorio: sistema,
|
|
645
|
+
})];
|
|
646
|
+
case 1:
|
|
647
|
+
_a.sent();
|
|
648
|
+
return [4 /*yield*/, this.sleep(this.buildDelayMs)];
|
|
649
|
+
case 2:
|
|
650
|
+
_a.sent();
|
|
651
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.unificarCommits, "/api/json"))];
|
|
652
|
+
case 3:
|
|
653
|
+
numbuild = _a.sent();
|
|
654
|
+
return [2 /*return*/, numbuild.builds[0].number];
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
BuildnatorClient.prototype.consultarUnificarCommits = function (id) {
|
|
660
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
661
|
+
var numbuild, _a;
|
|
662
|
+
return __generator(this, function (_b) {
|
|
663
|
+
switch (_b.label) {
|
|
664
|
+
case 0:
|
|
665
|
+
_b.trys.push([0, 2, , 3]);
|
|
666
|
+
return [4 /*yield*/, this.jenkinsPost("".concat(this.jobs.unificarCommits, "/").concat(id, "/api/json"))];
|
|
667
|
+
case 1:
|
|
668
|
+
numbuild = _b.sent();
|
|
669
|
+
if (numbuild && numbuild.inProgress === false) {
|
|
670
|
+
if (numbuild.result === "SUCCESS") {
|
|
671
|
+
return [2 /*return*/, { terminado: true, resultado: true, tipo: "unificar", retorno: numbuild.result }];
|
|
672
|
+
}
|
|
673
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "unificar", retorno: numbuild.result }];
|
|
674
|
+
}
|
|
675
|
+
return [2 /*return*/, { terminado: false, resultado: false, tipo: "unificar", retorno: numbuild === null || numbuild === void 0 ? void 0 : numbuild.result }];
|
|
676
|
+
case 2:
|
|
677
|
+
_a = _b.sent();
|
|
678
|
+
return [2 /*return*/, { terminado: true, resultado: false, tipo: "unificar", retorno: "erro interno" }];
|
|
679
|
+
case 3: return [2 /*return*/];
|
|
680
|
+
}
|
|
681
|
+
});
|
|
682
|
+
});
|
|
683
|
+
};
|
|
684
|
+
return BuildnatorClient;
|
|
685
|
+
}());
|
|
686
|
+
exports.BuildnatorClient = BuildnatorClient;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildnatorClient = void 0;
|
|
4
|
+
var buildnator_client_1 = require("./buildnator.client");
|
|
5
|
+
Object.defineProperty(exports, "BuildnatorClient", { enumerable: true, get: function () { return buildnator_client_1.BuildnatorClient; } });
|
package/dist/types.js
ADDED
package/index.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "buildnator-personal",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Biblioteca cliente para Jenkins do Buildnator",
|
|
5
|
+
"author": "Victor Rafael",
|
|
6
|
+
"license": "VR",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
12
|
+
"build": "tsc"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"axios": "^1.13.2"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^25.2.0",
|
|
19
|
+
"typescript": "^5.3.3"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "/buildnator-personal"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/tsconfig.json
ADDED
package/types.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type JobsConfig = {
|
|
2
|
+
agmCompila: string;
|
|
3
|
+
agbCompila: string;
|
|
4
|
+
agbCompilaVersao: string;
|
|
5
|
+
qaAgmLibera: string;
|
|
6
|
+
qaTaAgbLibera: string;
|
|
7
|
+
qaAgmLiberaEspecifica: string;
|
|
8
|
+
qaTaAgbLiberaEspecifica: string;
|
|
9
|
+
publicarDllsNuget: string;
|
|
10
|
+
testeTaVersaoEvolutiva: string;
|
|
11
|
+
unificarCommits: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type BuildnatorConfig = {
|
|
15
|
+
jenkins: {
|
|
16
|
+
baseUrl: string;
|
|
17
|
+
user: string;
|
|
18
|
+
token: string;
|
|
19
|
+
};
|
|
20
|
+
tls?: {
|
|
21
|
+
rejectUnauthorized?: boolean;
|
|
22
|
+
};
|
|
23
|
+
delays?: {
|
|
24
|
+
buildTriggerMs?: number;
|
|
25
|
+
recoverMs?: number;
|
|
26
|
+
};
|
|
27
|
+
jobs?: Partial<JobsConfig>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type QueryValue = string | number | boolean | undefined | null;
|