Skip to content

Commit 7a93c8f

Browse files
committed
fix: jenkinsfile
1 parent 2a2e1f8 commit 7a93c8f

1 file changed

Lines changed: 17 additions & 30 deletions

File tree

Jenkinsfile

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ LIBS_TESTS = [
2222
'abra': 'abra_tests',
2323
'ECS': 'r-type_ECS_sdk_tests'
2424
]
25+
FILE_EXTENSIONS = [
26+
'windows': ['exe', 'zip'],
27+
'unix': ['deb', 'zip']
28+
]
2529

2630
pipeline {
2731
agent any
@@ -120,12 +124,6 @@ pipeline {
120124
}
121125

122126
stages {
123-
stage('Checkout') {
124-
steps {
125-
checkout scm
126-
}
127-
}
128-
129127
stage('Generate build files') {
130128
steps {
131129
script {
@@ -213,7 +211,6 @@ pipeline {
213211
if (releaseId) {
214212
echo "Release created successfully"
215213
RELEASE_ID = releaseId
216-
ACCESS_TOKEN = GITHUB_ACCESS_TOKEN
217214
} else {
218215
echo "Failed to create release, it may already exist"
219216
}
@@ -246,13 +243,13 @@ pipeline {
246243
}
247244
}
248245

249-
stage('Generate installers') {
246+
stage('Generate artifacts') {
250247
steps {
251248
script {
252249
for (binary in BINARIES) {
253250
def TARGET_BINARY = BINARIES_TARGETS[binary]
254251

255-
stage ("${binary}") {
252+
stage ("${binary} artifacts") {
256253
bat "cmake --preset=windows:release:${binary}"
257254
bat "cmake --build build/windows/release --config release --target r-type_${binary}"
258255
bat "cd build/windows/release && cpack -C release"
@@ -268,29 +265,19 @@ pipeline {
268265
withCredentials([usernamePassword(credentialsId: '097d37a7-4a1b-4fc6-ba70-e13f043b70e8',
269266
usernameVariable: 'GITHUB_APP',
270267
passwordVariable: 'GITHUB_ACCESS_TOKEN')]) {
271-
bat """
272-
echo GITHUB_APP=%GITHUB_APP%
273-
"""
274268
for (binary in BINARIES) {
275-
def filename = "R-Type-${binary}-${VERSION}.zip"
276-
echo "Uploading ${filename}"
277-
if (ACCESS_TOKEN) {
278-
echo "Access Token"
269+
for (ext in FILE_EXTENSIONS) {
270+
def filename = "R-Type-${binary}-${VERSION}.${ext}"
271+
bat """
272+
curl -L \
273+
-X POST \
274+
-H "Accept: application/vnd.github+json" \
275+
-H "Authorization: Bearer %GITHUB_ACCESS_TOKEN%" \
276+
-H "Content-Type: application/octet-stream" \
277+
"https://uploads.github.com/repos/G-Epitech/DFMY-RType/releases/${RELEASE_ID}/assets?name=${filename}" \
278+
--data-binary "@build/windows/release/${filename}"
279+
"""
279280
}
280-
def response = bat(script: """
281-
curl -L \
282-
-X POST \
283-
-H "Accept: application/vnd.github+json" \
284-
-H "Authorization: Bearer %GITHUB_ACCESS_TOKEN%" \
285-
-H "Content-Type: application/octet-stream" \
286-
"https://uploads.github.com/repos/G-Epitech/DFMY-RType/releases/${RELEASE_ID}/assets?name=${filename}" \
287-
--data-binary "@build/windows/release/${filename}"
288-
""", returnStdout: true)
289-
echo "Response: ${response}"
290-
def jsonResponse = readJSON(text: response)
291-
echo "Upload URL: ${jsonResponse.url}"
292-
def status = jsonResponse.state
293-
echo "Upload status: ${status}"
294281
}
295282
}
296283
}

0 commit comments

Comments
 (0)