From 465bca219220e70d4a23c7af09e84b9db19f6e2d Mon Sep 17 00:00:00 2001 From: Voomra Date: Mon, 18 Aug 2025 14:14:54 +0300 Subject: [PATCH] =?UTF-8?q?build(ci):=20fix=20=D0=B8=D1=81=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D1=8F=D0=BC=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .jenkinsfile | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/.jenkinsfile b/.jenkinsfile index 81e21bc..312adb4 100644 --- a/.jenkinsfile +++ b/.jenkinsfile @@ -32,19 +32,16 @@ pipeline { } """ - def connection = new URL(env.GITEA_API_URL).openConnection() as HttpURLConnection - connection.setRequestMethod("POST") - connection.setRequestProperty("Authorization", "token ${env.GITEA_TOKEN}") - connection.setRequestProperty("Content-Type", "application/json") - connection.doOutput = true + def responseApi = httpRequest( + url: env.GITEA_API_URL, + httpMode: 'POST', + acceptType: 'application/json', + contentType: 'application/json' + customHeaders: [[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"]] + requestBody: releaseData) - def writer = new OutputStreamWriter(connection.outputStream) - writer.write(releaseData) - writer.flush() - writer.close() - - def responseCode = connection.responseCode - def responseBody = connection.inputStream.text + def responseCode = responseApi.status + def responseBody = responseApi.content if (responseCode != 201) { error """ @@ -76,20 +73,20 @@ pipeline { def fileName = file.name echo "Загружаем файл: ${fileName}" - def connection = new URL("${env.GITEA_API_URL}/${env.RELEASE_ID}/assets?name=${fileName}").openConnection() as HttpURLConnection - connection.setRequestMethod("POST") - connection.setRequestProperty("Authorization", "token ${env.GITEA_TOKEN}") - connection.setRequestProperty("Content-Type", "application/octet-stream") - connection.doOutput = true + def responseApi = httpRequest( + url: "${env.GITEA_API_URL}/${env.RELEASE_ID}/assets?name=${fileName}", + httpMode: 'POST', + acceptType: 'application/json', + contentType: 'application/octet-stream' + customHeaders: [[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"]] + uploadFile: "build/libs/${fileName}") - def fileBytes = new File("build/libs/${fileName}").bytes - connection.outputStream.write(fileBytes) + def responseCode = responseApi.status - def uploadResponseCode = connection.responseCode - if (uploadResponseCode != 201) { + if (responseCode != 201) { echo """ - ⚠️ Ошибка загрузки ${fileName}: статус ${uploadResponseCode} - Тело ответа: ${connection.inputStream.text} + ⚠️ Ошибка загрузки ${fileName}: статус ${responseCode} + Тело ответа: ${responseApi.content} """ } }