1 | <?php |
||
13 | class Job |
||
14 | { |
||
15 | const BASE_NAME = 'jolici'; |
||
16 | |||
17 | /** |
||
18 | * @var string Name of job |
||
19 | */ |
||
20 | protected $project; |
||
21 | |||
22 | /** |
||
23 | * @var string Strategy associated with this job |
||
24 | */ |
||
25 | protected $strategy; |
||
26 | |||
27 | /** |
||
28 | * @var string Uniq key for this "kind" of job |
||
29 | * |
||
30 | * This key is not a identifier (the name is the identifier in a job), it's more like a category, |
||
31 | * job with same parameters MUST have the same uniq key, this key is use to track the history |
||
32 | * of a job over time (for cleaning, reports, etc ....) |
||
33 | */ |
||
34 | protected $uniq; |
||
35 | |||
36 | /** |
||
37 | * @var array Parameters of this job |
||
38 | * |
||
39 | * It mainly depend on the strategy, ie for TravisCi strategy this will include the language used, version used, etc ... |
||
40 | */ |
||
41 | protected $parameters; |
||
42 | |||
43 | /** |
||
44 | * @var string Description of this job (generally a nice name for end user) |
||
45 | */ |
||
46 | protected $description; |
||
47 | |||
48 | /** |
||
49 | * @var \DateTime Date of creation of the job |
||
50 | */ |
||
51 | protected $created; |
||
52 | |||
53 | /** |
||
54 | * @var Service[] Services linked to this job |
||
55 | */ |
||
56 | private $services = array(); |
||
57 | |||
58 | /** |
||
59 | * @param string $project Project of the job |
||
60 | * @param string $strategy Strategy of the job |
||
61 | * @param string $uniq A uniq identifier for this kind of job |
||
62 | * @param array $parameters Parameters of the job (mainly depend on the strategy) |
||
63 | * @param string $description Description of this job (generally a nice name for end user) |
||
64 | * @param \DateTime $created Date of creation of the job |
||
65 | * @param array $services Services linked to the job |
||
66 | */ |
||
67 | public function __construct($project, $strategy, $uniq, $parameters = array(), $description = "", $created = null, $services = array()) |
||
82 | |||
83 | /** |
||
84 | * Get name of this job |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getName() |
||
92 | |||
93 | /** |
||
94 | * Get repository name for docker images job with this strategy |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | public function getRepository() |
||
102 | |||
103 | /** |
||
104 | * Generate the tag name for a docker image |
||
105 | * |
||
106 | * @return string |
||
107 | */ |
||
108 | public function getTag() |
||
112 | |||
113 | /** |
||
114 | * Add a service to the job |
||
115 | * |
||
116 | * @param Service $service |
||
117 | */ |
||
118 | public function addService(Service $service) |
||
122 | |||
123 | /** |
||
124 | * Return all services linked to this job |
||
125 | * |
||
126 | * @return Service[] |
||
127 | */ |
||
128 | public function getServices() |
||
132 | |||
133 | /** |
||
134 | * Return directory of job |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function getDirectory() |
||
142 | |||
143 | /** |
||
144 | * @return string |
||
145 | */ |
||
146 | public function getDescription() |
||
150 | |||
151 | /** |
||
152 | * @return string |
||
153 | */ |
||
154 | public function getStrategy() |
||
158 | |||
159 | /** |
||
160 | * @return string |
||
161 | */ |
||
162 | public function getUniq() |
||
166 | |||
167 | /** |
||
168 | * @return array |
||
169 | */ |
||
170 | public function getParameters() |
||
174 | |||
175 | /** |
||
176 | * @return \DateTime |
||
177 | */ |
||
178 | public function getCreated() |
||
182 | |||
183 | public function __toString() |
||
187 | } |
||
188 |