modified jenkins file
This commit is contained in:
Vendored
+20
-8
@@ -45,17 +45,29 @@ def process_folder(folder, import_type) {
|
|||||||
|
|
||||||
sh "mkdir -p ${backup_folder}"
|
sh "mkdir -p ${backup_folder}"
|
||||||
|
|
||||||
files = findFiles(glob: "${folder}/*.xml")
|
// Use find command to get XML files and avoid error if none found
|
||||||
|
def fileList = sh(script: "find ${folder} -name '*.xml' || echo ''", returnStdout: true).trim().split('\n')
|
||||||
|
|
||||||
for(file in files) {
|
// Remove any empty strings from the list
|
||||||
response = sh(script: """
|
fileList = fileList.findAll { it != '' }
|
||||||
curl --location --request POST "${import_url}" \
|
|
||||||
--header "Authorization: ${env.AUTH_TOKEN}" \
|
// Check if we found any files
|
||||||
--form "@${file}" \
|
if (fileList.size() == 0) {
|
||||||
""", returnStdout: true).trim()
|
echo "No XML files found in ${folder}."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Detected files: ${fileList.join(', ')}"
|
||||||
|
|
||||||
|
for(file in fileList) {
|
||||||
|
def response = sh(script: """
|
||||||
|
curl --location --request POST "${import_url}" \
|
||||||
|
--header 'Authorization: stat ${env.AUTH_TOKEN}' \
|
||||||
|
--form "=@${file}"
|
||||||
|
""", returnStdout: true).trim()
|
||||||
|
|
||||||
if(response != '') { // or other success condition
|
if(response != '') { // or other success condition
|
||||||
sh "mv ${file} ${backup_folder}/"
|
sh "mv \"${file}\" \"${backup_folder}/\""
|
||||||
echo "API Response: ${response}"
|
echo "API Response: ${response}"
|
||||||
} else {
|
} else {
|
||||||
echo "Error while uploading ${file} to ${import_url}"
|
echo "Error while uploading ${file} to ${import_url}"
|
||||||
|
|||||||
Viittaa uudesa ongelmassa
Block a user