6 コミット

作成者 SHA1 メッセージ 日付
  Avinash 93b1276d0b added forms 2年前
  Avinash ae186e2a55 added report 2年前
  Avinash 2da9807fa0 modified jenkins file 2年前
  jenkinstest 38a469f50c Moved processed XML files to backup 2年前
  devops.bizgaze 357bc98ef0 added jenkins file 2年前
  Avinash e4dba442de added reports for test08 2年前

+ 94
- 0
.jenkins/Jenkinsfile ファイルの表示

@@ -0,0 +1,94 @@
1
+pipeline {
2
+    agent any
3
+
4
+    environment {
5
+        BACKUP_DIR = './backup'
6
+    }
7
+
8
+    stages {
9
+        stage('Setup') {
10
+            steps {
11
+                script {
12
+                    BRANCH_NAME = env.BRANCH_NAME.split('/')[-1] // Extract branch name
13
+
14
+                    switch(BRANCH_NAME) {
15
+                        case "test1":
16
+                            env.BASE_URL = "https://test08.bizgaze.com/Account/Import/"
17
+                            env.AUTH_TOKEN = "6884972896664f4582e08f7f93da953d"
18
+                            break
19
+                        case "anwiqa":
20
+                            env.BASE_URL = "https://qa.anwisystems.com/Account/Import/"
21
+                            env.AUTH_TOKEN = "541c35d52a7b449f956175992619ed3a"
22
+                            break
23
+                        default:
24
+                            error "Unknown branch: ${BRANCH_NAME}. Exiting."
25
+                    }
26
+                }
27
+            }
28
+        }
29
+
30
+        stage('Process XML files') {
31
+            steps {
32
+                script {
33
+                    process_folder('./app', 'app')
34
+                    process_folder('./report', 'report')
35
+                    process_folder('./form', 'form')
36
+                    commitChanges()
37
+                }
38
+            }
39
+        }
40
+    }
41
+}
42
+
43
+def process_folder(folder, import_type) {
44
+    import_url = "${env.BASE_URL}${import_type}"
45
+    backup_folder = "${env.BACKUP_DIR}/${import_type}"
46
+
47
+    sh "mkdir -p ${backup_folder}"
48
+
49
+    // Use find command to get XML files and avoid error if none found
50
+    def fileList = sh(script: "find ${folder} -name '*.xml' || echo ''", returnStdout: true).trim().split('\n')
51
+
52
+    // Remove any empty strings from the list
53
+    fileList = fileList.findAll { it != '' }
54
+
55
+    // Check if we found any files
56
+    if (fileList.size() == 0) {
57
+        echo "No XML files found in ${folder}."
58
+        return
59
+    }
60
+
61
+    echo "Detected files: ${fileList.join(', ')}"
62
+
63
+    for(file in fileList) {
64
+        def response = sh(script: """
65
+    curl --location --request POST "${import_url}" \
66
+    --header 'Authorization: stat ${env.AUTH_TOKEN}' \
67
+    --form "=@${file}"
68
+    """, returnStdout: true).trim()
69
+
70
+        if(response != '') { // or other success condition
71
+            sh "mv \"${file}\" \"${backup_folder}/\""
72
+            echo "API Response: ${response}"
73
+        } else {
74
+            echo "Error while uploading ${file} to ${import_url}"
75
+        }
76
+    }
77
+}
78
+
79
+def commitChanges() {
80
+    // Configure Git
81
+    sh """
82
+        git config user.email "jenkins@bizgaze.in"
83
+        git config user.name "jenkinstest"
84
+    """
85
+
86
+    // Check for changes
87
+    sh """
88
+        git checkout ${env.BRANCH_NAME}
89
+        git add .
90
+        git commit -m "Moved processed XML files to backup"
91
+        git push https://jenkinstest:Bizgaze123@code.bizgaze.com/devops.bizgaze/imports.git ${env.BRANCH_NAME}
92
+    """
93
+}
94
+

+ 2
- 2
Jenkinsfile ファイルの表示

@@ -85,10 +85,10 @@ def commitChanges() {
85 85
 
86 86
     // Check for changes
87 87
     sh """
88
-        git pull origin ${env.BRANCH_NAME}
88
+        git checkout ${env.BRANCH_NAME}
89 89
         git add .
90 90
         git commit -m "Moved processed XML files to backup"
91
-        git push --force https://jenkinstest:Bizgaze123@code.bizgaze.com/devops.bizgaze/imports.git ${env.BRANCH_NAME}
91
+        git push https://jenkinstest:Bizgaze123@code.bizgaze.com/devops.bizgaze/imports.git ${env.BRANCH_NAME}
92 92
     """
93 93
 }
94 94
 

form/Branches Create Contact Point - Form.xml → backup/form/Branches Create Contact Point - Form.xml ファイルの表示


form/partners Create Contact Point - Form.xml → backup/form/partners Create Contact Point - Form.xml ファイルの表示


form/vendors Create Contact Point - Form.xml → backup/form/vendors Create Contact Point - Form.xml ファイルの表示


+ 1
- 0
backup/report/Branches Create Contact Point - Form.xml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1
- 0
backup/report/partners Create Contact Point - Form.xml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1
- 0
backup/report/vendors Create Contact Point - Form.xml
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 0
- 22
report/Sales Invoice.xml
ファイル差分が大きすぎるため省略します
ファイルの表示


読み込み中…
キャンセル
保存