-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkinsjob.h
129 lines (101 loc) · 2.87 KB
/
jenkinsjob.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef JENKINSJOB_H
#define JENKINSJOB_H
#include <QIcon>
#include <QMap>
#include <QDateTime>
namespace JenkinsCI
{
namespace Internal
{
/*!
* \brief The HealthReport class holds information about health status of job. Use "healthReport" part
* in JSON reply
*/
class HealthReport
{
public:
HealthReport() = default;
HealthReport(const int score, const QString &description,
const QString &iconClassName = QString());
QString description() const;
void setDescription(const QString &description);
int score() const;
void setScore(int score);
QString iconClassName() const;
void setIconClassName(const QString &iconClassName);
QString getIconFile() const { return ICON_CLASS_ICONS.value(_iconClassName); }
private:
static const QMap< QString, QString > ICON_CLASS_ICONS;
int _score{-1};
QString _description;
QString _iconClassName;
};
/*!
* \brief The JenkinsJob class holds information about job. Use entry of "jobs" array in JSON reply
*/
class JenkinsJob
{
public:
struct BuildUrl
{
BuildUrl() {}
BuildUrl(const int buildNumber, const QString buildUrl) : number(buildNumber), url(buildUrl)
{
}
int number{1};
QString url;
bool operator==(const BuildUrl &rhs) const
{
return number == rhs.number && url == rhs.url;
}
};
enum BuildStatus
{
Success,
Unstable,
NotBuilt,
Fail,
Unknown
};
JenkinsJob() {}
QString jobUrl() const;
void setJobUrl(const QString &jobUrl);
QString name() const;
void setName(const QString &name);
void setBuildStatus(const QString &colorEntry);
bool isValid() { return !_jobUrl.isEmpty() && !_name.isEmpty(); }
bool isRunning() const;
QString colorIcon() const;
QList< HealthReport > healthReports() const;
void setHealthReports(const QList< HealthReport > &healthReports);
QIcon healthIcon() const;
QList< BuildUrl > buildUrls() const;
void setBuildUrls(const QList< BuildUrl > &buildUrls);
BuildUrl getLastBuildUrl() const;
QString healthIconPath() const;
bool isBuildable() const;
void setIsBuildable(bool isBuildable);
bool isQueued() const;
void setIsQueued(bool isQueued);
QDateTime lastBuildDate() const;
void setLastBuildDate(const QDateTime &lastBuildDate);
void setLastBuildDate(const quint64 ×tamp);
BuildStatus buildStatus() const;
private:
QIcon _healthIcon;
QString _healthIconPath;
QString _jobUrl;
QString _name;
QString _color;
QList< HealthReport > _healthReports;
QList< BuildUrl > _buildUrls;
bool _isRunning{false};
QString _colorIcon;
bool _isBuildable{true};
bool _isQueued{false};
QDateTime _lastBuildDate;
BuildStatus _buildStatus{BuildStatus::Unknown};
};
}
}
#endif // JENKINSJOB_H