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
|
def responseApi = httpRequest(
|
||||||
connection.setRequestMethod("POST")
|
url: env.GITEA_API_URL,
|
||||||
connection.setRequestProperty("Authorization", "token ${env.GITEA_TOKEN}")
|
httpMode: 'POST',
|
||||||
connection.setRequestProperty("Content-Type", "application/json")
|
acceptType: 'application/json',
|
||||||
connection.doOutput = true
|
contentType: 'application/json'
|
||||||
|
customHeaders: [[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"]]
|
||||||
|
requestBody: releaseData)
|
||||||
|
|
||||||
def writer = new OutputStreamWriter(connection.outputStream)
|
def responseCode = responseApi.status
|
||||||
writer.write(releaseData)
|
def responseBody = responseApi.content
|
||||||
writer.flush()
|
|
||||||
writer.close()
|
|
||||||
|
|
||||||
def responseCode = connection.responseCode
|
|
||||||
def responseBody = connection.inputStream.text
|
|
||||||
|
|
||||||
if (responseCode != 201) {
|
if (responseCode != 201) {
|
||||||
error """
|
error """
|
||||||
@@ -76,20 +73,20 @@ pipeline {
|
|||||||
def fileName = file.name
|
def fileName = file.name
|
||||||
echo "Загружаем файл: ${fileName}"
|
echo "Загружаем файл: ${fileName}"
|
||||||
|
|
||||||
def connection = new URL("${env.GITEA_API_URL}/${env.RELEASE_ID}/assets?name=${fileName}").openConnection() as HttpURLConnection
|
def responseApi = httpRequest(
|
||||||
connection.setRequestMethod("POST")
|
url: "${env.GITEA_API_URL}/${env.RELEASE_ID}/assets?name=${fileName}",
|
||||||
connection.setRequestProperty("Authorization", "token ${env.GITEA_TOKEN}")
|
httpMode: 'POST',
|
||||||
connection.setRequestProperty("Content-Type", "application/octet-stream")
|
acceptType: 'application/json',
|
||||||
connection.doOutput = true
|
contentType: 'application/octet-stream'
|
||||||
|
customHeaders: [[name: 'Authorization', value: "token ${env.GITEA_TOKEN}"]]
|
||||||
|
uploadFile: "build/libs/${fileName}")
|
||||||
|
|
||||||
def fileBytes = new File("build/libs/${fileName}").bytes
|
def responseCode = responseApi.status
|
||||||
connection.outputStream.write(fileBytes)
|
|
||||||
|
|
||||||
def uploadResponseCode = connection.responseCode
|
if (responseCode != 201) {
|
||||||
if (uploadResponseCode != 201) {
|
|
||||||
echo """
|
echo """
|
||||||
⚠️ Ошибка загрузки ${fileName}: статус ${uploadResponseCode}
|
⚠️ Ошибка загрузки ${fileName}: статус ${responseCode}
|
||||||
Тело ответа: ${connection.inputStream.text}
|
Тело ответа: ${responseApi.content}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user