1 | #pragma once |
---|---|
2 | |
3 | #include <Colors.h> |
4 | |
5 | #include <QDateTime> |
6 | #include <QString> |
7 | #include <QMap> |
8 | #include <QMetaType> |
9 | #include <QColor> |
10 | #include <QVariant> |
11 | #include <QVector> |
12 | |
13 | namespace Jenkins |
14 | { |
15 | |
16 | inline QColor resultColor(const QString &result) |
17 | { |
18 | if (result == "SUCCESS") |
19 | return jenkinsResultSuccess; |
20 | else if (result == "UNSTABLE") |
21 | return gitQlientOrange; |
22 | else if (result == "FAILURE"|| result == "FAILED") |
23 | return jenkinsResultFailure; |
24 | else if (result == "ABORTED") |
25 | return jenkinsResultAborted; |
26 | else |
27 | return jenkinsResultNotBuilt; |
28 | } |
29 | |
30 | struct JenkinsStageInfo |
31 | { |
32 | int id; |
33 | QString name; |
34 | QString url; |
35 | int duration; |
36 | QString result; |
37 | }; |
38 | |
39 | struct JenkinsJobBuildInfo |
40 | { |
41 | struct Artifact |
42 | { |
43 | QString fileName; |
44 | QString url; |
45 | }; |
46 | |
47 | bool operator==(const JenkinsJobBuildInfo &build) const { return url == build.url; } |
48 | |
49 | int number; |
50 | QString url; |
51 | QDateTime date; |
52 | int duration; |
53 | QString result; |
54 | QString user; |
55 | QVector<Artifact> artifacts; |
56 | QVector<JenkinsStageInfo> stages; |
57 | }; |
58 | |
59 | enum class JobConfigFieldType |
60 | { |
61 | Bool, |
62 | String, |
63 | Choice |
64 | }; |
65 | |
66 | struct JenkinsJobBuildConfig |
67 | { |
68 | JobConfigFieldType fieldType; |
69 | QString name; |
70 | QVariant defaultValue; |
71 | QStringList choicesValues; |
72 | }; |
73 | |
74 | struct JenkinsJobInfo |
75 | { |
76 | bool operator==(const JenkinsJobInfo &info) const { return name == info.name; } |
77 | bool operator!=(const JenkinsJobInfo &info) const { return !(name == info.name); } |
78 | bool operator<(const JenkinsJobInfo &info) const { return name < info.name; } |
79 | |
80 | struct HealthStatus |
81 | { |
82 | QString score; |
83 | QString description; |
84 | QString iconClassName; |
85 | }; |
86 | |
87 | QString name; |
88 | QString url; |
89 | QString color; |
90 | bool buildable; |
91 | bool inQueue; |
92 | HealthStatus healthStatus; |
93 | QVector<JenkinsJobBuildInfo> builds; |
94 | QVector<JenkinsJobBuildConfig> configFields; |
95 | }; |
96 | |
97 | } |
98 | |
99 | Q_DECLARE_METATYPE(Jenkins::JenkinsJobInfo); |
100 |