Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. pipeline {
  2. agent any
  3. environment {
  4. BACKUP_DIR = './backup'
  5. }
  6. stages {
  7. stage('Setup') {
  8. steps {
  9. script {
  10. BRANCH_NAME = env.BRANCH_NAME.split('/')[-1] // Extract branch name
  11. switch(BRANCH_NAME) {
  12. case "test1":
  13. env.BASE_URL = "https://test08.bizgaze.com/Account/Import/"
  14. env.AUTH_TOKEN = "6884972896664f4582e08f7f93da953d"
  15. break
  16. case "anwiqa":
  17. env.BASE_URL = "https://qa.anwisystems.com/Account/Import/"
  18. env.AUTH_TOKEN = "541c35d52a7b449f956175992619ed3a"
  19. break
  20. default:
  21. error "Unknown branch: ${BRANCH_NAME}. Exiting."
  22. }
  23. }
  24. }
  25. }
  26. stage('Process XML files') {
  27. steps {
  28. script {
  29. process_folder('./app', 'app')
  30. process_folder('./report', 'report')
  31. process_folder('./form', 'form')
  32. }
  33. }
  34. }
  35. }
  36. }
  37. def process_folder(folder, import_type) {
  38. import_url = "${env.BASE_URL}${import_type}"
  39. backup_folder = "${env.BACKUP_DIR}/${import_type}"
  40. sh "mkdir -p ${backup_folder}"
  41. files = findFiles(glob: "${folder}/*.xml")
  42. for(file in files) {
  43. response = sh(script: """
  44. curl --location --request POST "${import_url}" \
  45. --header "Authorization: ${env.AUTH_TOKEN}" \
  46. --form "@${file}" \
  47. """, returnStdout: true).trim()
  48. if(response != '') { // or other success condition
  49. sh "mv ${file} ${backup_folder}/"
  50. echo "API Response: ${response}"
  51. } else {
  52. echo "Error while uploading ${file} to ${import_url}"
  53. }
  54. }
  55. }