modified jenkins file

此提交包含在:
2023-10-13 15:31:26 +05:30
父節點 97c2a603d0
當前提交 a3fa085663
已供應
+20 -8
查看文件
@@ -45,17 +45,29 @@ def process_folder(folder, import_type) {
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) {
response = sh(script: """
curl --location --request POST "${import_url}" \
--header "Authorization: ${env.AUTH_TOKEN}" \
--form "@${file}" \
""", returnStdout: true).trim()
// Remove any empty strings from the list
fileList = fileList.findAll { it != '' }
// Check if we found any files
if (fileList.size() == 0) {
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
sh "mv ${file} ${backup_folder}/"
sh "mv \"${file}\" \"${backup_folder}/\""
echo "API Response: ${response}"
} else {
echo "Error while uploading ${file} to ${import_url}"