build(ci): fix использование прямого кода
This commit is contained in:
43
.jenkinsfile
43
.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}
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user