1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.maven.plugins.jenkins.helper;
17
18 import java.io.File;
19 import java.io.FileFilter;
20 import java.io.IOException;
21 import java.text.SimpleDateFormat;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Date;
25 import java.util.HashMap;
26 import java.util.List;
27 import java.util.Map;
28 import java.util.Properties;
29
30 import org.apache.maven.artifact.Artifact;
31 import org.apache.maven.project.MavenProject;
32 import org.codehaus.plexus.util.StringUtils;
33 import org.kuali.maven.common.Extractor;
34 import org.kuali.maven.common.PropertiesUtils;
35 import org.kuali.maven.common.ResourceUtils;
36 import org.kuali.maven.plugins.jenkins.BaseMojo;
37 import org.kuali.maven.plugins.jenkins.CliMojo;
38 import org.kuali.maven.plugins.jenkins.Command;
39 import org.kuali.maven.plugins.jenkins.DeleteJobMojo;
40 import org.kuali.maven.plugins.jenkins.DeleteJobsMojo;
41 import org.kuali.maven.plugins.jenkins.GenJobMojo;
42 import org.kuali.maven.plugins.jenkins.GenJobsMojo;
43 import org.kuali.maven.plugins.jenkins.GetJobMojo;
44 import org.kuali.maven.plugins.jenkins.GetJobsMojo;
45 import org.kuali.maven.plugins.jenkins.PushJobsMojo;
46 import org.kuali.maven.plugins.jenkins.RunJobCommand;
47 import org.kuali.maven.plugins.jenkins.RunJobMojo;
48 import org.kuali.maven.plugins.jenkins.RunJobsMojo;
49 import org.kuali.maven.plugins.jenkins.SimpleJobCommand;
50 import org.kuali.maven.plugins.jenkins.context.GAV;
51 import org.kuali.maven.plugins.jenkins.context.JenkinsException;
52 import org.kuali.maven.plugins.jenkins.context.ProcessContext;
53 import org.kuali.maven.plugins.jenkins.context.ProcessResult;
54 import org.slf4j.Logger;
55 import org.slf4j.LoggerFactory;
56
57 public class JenkinsHelper {
58
59 private final Logger logger = LoggerFactory.getLogger(JenkinsHelper.class);
60
61 public static final String XML_EXTENSION = ".xml";
62 public static final int SUCCESS_CODE = 0;
63 public static final int NO_SUCH_COMMAND = 255;
64 public static final String SERVER_ARG = "-s";
65 public static final String NONE = "NONE";
66 public static final String DASH = "-";
67 public static final String FS = System.getProperty("file.separator");
68
69 Extractor extractor = new Extractor();
70 PropertiesUtils propertiesUtils = new PropertiesUtils();
71 ResourceUtils resourceUtils = new ResourceUtils();
72 JavaHelper javaHelper = new JavaHelper();
73 CommandHelper cmdHelper = new CommandHelper();
74
75 protected List<String> getNamesList(String csvNames, List<String> names) {
76 if (!Helper.isEmpty(names)) {
77 return names;
78 } else {
79 return Helper.splitAndTrimCSVToList(csvNames);
80 }
81 }
82
83 protected List<String> getJobNames(BaseMojo mojo, String csvNames, List<String> names) {
84 List<String> namesList = getNamesList(csvNames, names);
85 List<String> newNames = new ArrayList<String>();
86 for (String name : namesList) {
87 String newName = getJobName(mojo, name);
88 newNames.add(newName);
89 }
90 return newNames;
91 }
92
93 public void execute(GetJobMojo mojo) {
94 List<String> jobNames = getJobNames(mojo, mojo.getName(), null);
95 List<Command> commands = createGetJobCommands(mojo, mojo.getCmd(), jobNames);
96 executeCli(mojo, commands);
97 }
98
99 public void execute(GetJobsMojo mojo) {
100 List<String> jobNames = getJobNames(mojo, mojo.getNames(), mojo.getNameList());
101 List<Command> commands = createGetJobCommands(mojo, mojo.getCmd(), jobNames);
102 executeCli(mojo, commands);
103 }
104
105 protected List<Command> createGetJobCommands(BaseMojo mojo, String cmd, List<String> jobNames) {
106 List<Command> commands = new ArrayList<Command>();
107 for (String jobName : jobNames) {
108 Command command = createGetJobCommand(mojo, cmd, jobName);
109 commands.add(command);
110 }
111 return commands;
112 }
113
114 protected Command createGetJobCommand(BaseMojo mojo, String cmd, String jobName) {
115 String filename = mojo.getWorkingDir() + FS + jobName + XML_EXTENSION;
116 String[] args = { cmd, jobName };
117 Command command = new Command();
118 command.setArgs(Arrays.asList(args));
119 command.setStdout(new File(filename));
120 return command;
121 }
122
123 protected GAV getGav(Properties properties) {
124 String groupId = properties.getProperty("jenkins.cli.groupId");
125 String artifactId = properties.getProperty("jenkins.cli.artifactId");
126 String version = properties.getProperty("jenkins.cli.version");
127 if (Helper.anyAreBlank(groupId, artifactId, version)) {
128 return null;
129 }
130 GAV gav = new GAV();
131 gav.setVersion(version);
132 gav.setArtifactId(artifactId);
133 gav.setGroupId(groupId);
134 return gav;
135 }
136
137 protected GAV getGav(Artifact artifact) {
138 GAV gav = new GAV();
139 gav.setGroupId(artifact.getGroupId());
140 gav.setArtifactId(artifact.getArtifactId());
141 gav.setVersion(artifact.getVersion());
142 return gav;
143 }
144
145 protected GAV getGav(MavenProject project) {
146 try {
147 String location = "classpath:org/kuali/maven/plugins/jenkins/jenkins-cli.properties";
148 Properties internal = propertiesUtils.getProperties(location);
149 GAV internalGAV = getGav(internal);
150 GAV overrideGAV = getGav(project.getProperties());
151
152 GAV gav = internalGAV;
153 if (overrideGAV != null && !internalGAV.equals(overrideGAV)) {
154 logger.info("Jenkins CLI override: [internal=" + internalGAV + ", override=" + overrideGAV + "]");
155 gav = overrideGAV;
156 }
157 return gav;
158 } catch (IOException e) {
159 throw new JenkinsException(e);
160 }
161
162 }
163
164 protected File getJenkinsJar(MavenProject project, List<Artifact> pluginArtifacts) {
165 GAV gav = getGav(project);
166 File jar = getJar(gav, pluginArtifacts);
167 if (jar == null) {
168 throw new JenkinsException("Unable to locate jenkins-cli.jar");
169 } else {
170 return jar;
171 }
172 }
173
174 protected File getJar(GAV gav, List<Artifact> artifacts) {
175 for (Artifact artifact : artifacts) {
176 if (equals(artifact, gav)) {
177 return artifact.getFile();
178 }
179 }
180 return null;
181 }
182
183 protected boolean equals(Artifact artifact, GAV gav) {
184 GAV artifactGav = getGav(artifact);
185 return artifactGav.equals(gav);
186 }
187
188 protected List<File> getFiles(File workingDir) {
189 if (!workingDir.exists()) {
190 return new ArrayList<File>();
191 }
192 FileFilter filter = new XmlFileFilter();
193 File[] files = workingDir.listFiles(filter);
194 return Arrays.asList(files);
195 }
196
197 protected void pushJobs(BaseMojo mojo, String cmd) {
198 try {
199 List<Command> commands = getCommands(mojo.getWorkingDir(), cmd);
200 executeCli(mojo, commands);
201 } catch (IOException e) {
202 throw new JenkinsException(e);
203 }
204
205 }
206
207 protected List<Command> getCommands(File workingDir, String cmd) throws IOException {
208 List<File> files = getFiles(workingDir);
209 List<Command> commands = new ArrayList<Command>();
210 for (File file : files) {
211 Command command = getCommand(file, cmd);
212 commands.add(command);
213 }
214 return commands;
215 }
216
217 protected String getJobName(File file) {
218 String name = file.getName();
219 int pos = name.lastIndexOf(XML_EXTENSION);
220 return name.substring(0, pos);
221 }
222
223 protected Command getCommand(File file, String cmd) throws IOException {
224 String stdin = resourceUtils.read(file.getAbsolutePath());
225 String jobName = getJobName(file);
226 String[] args = { cmd, jobName };
227 Command command = new Command();
228 command.setStdin(stdin);
229 command.setArgs(Arrays.asList(args));
230 return command;
231 }
232
233 protected String getInput(Command cmd) {
234 if (!StringUtils.isBlank(cmd.getStdinUrl())) {
235 try {
236 return resourceUtils.read(cmd.getStdinUrl());
237 } catch (IOException e) {
238 throw new JenkinsException(e);
239 }
240 } else {
241 return cmd.getStdin();
242 }
243 }
244
245 protected ProcessResult executeCli(File jar, String url, Command cmd) {
246 String input = getInput(cmd);
247 return executeCli(jar, url, cmd.getArgs(), input);
248 }
249
250 protected ProcessResult executeCli(File jar, String url, List<String> args, String input) {
251 String[] cliArgs = getCliArgs(url, args);
252 return javaHelper.executeJar(jar, cliArgs, input);
253 }
254
255 protected String[] getCliArgs(String url, List<String> args) {
256 List<String> list = new ArrayList<String>();
257 list.add(SERVER_ARG);
258 list.add(url);
259 list.addAll(args);
260 return Helper.toArray(list);
261 }
262
263 protected int[] getSuccessCodes(BaseMojo mojo) {
264 String csv = mojo.getSuccessCodes();
265 return Helper.toIntArray(csv);
266 }
267
268 protected void handleResult(Command command, ProcessResult result, BaseMojo mojo) {
269 int[] successCodes = getSuccessCodes(mojo);
270 int exitValue = result.getExitValue();
271 if (Helper.isMatch(exitValue, successCodes)) {
272 handleSuccess(mojo, command, result);
273 } else {
274 handleFailure(mojo, result);
275 }
276 }
277
278 protected void logInfo(List<String> lines) {
279 if (lines.size() == 0) {
280 return;
281 }
282 for (String line : lines) {
283 logger.info(line);
284 }
285 }
286
287 protected void logError(List<String> lines) {
288 String top = getTop(lines);
289 if (top != null) {
290 logger.error(top);
291 }
292 }
293
294 protected void logWarning(List<String> lines) {
295 String top = getTop(lines);
296 if (top != null) {
297 logger.warn(top);
298 }
299 }
300
301 protected String getTop(List<String> lines) {
302 for (String line : lines) {
303 if (!StringUtils.isBlank(line)) {
304 return line;
305 }
306 }
307 return null;
308 }
309
310 protected void handleFailure(BaseMojo mojo, ProcessResult result) {
311 if (mojo.isStopOnError()) {
312 logger.error("Jenkins CLI Exception:" + getErrorMessage(mojo, result));
313 throw new JenkinsException("Jenkins CLI Exception");
314 } else {
315 if (mojo.isFailOnError()) {
316 logError(result.getOutputLines());
317 } else {
318 logWarning(result.getOutputLines());
319 }
320 }
321 }
322
323 protected void handleSuccess(BaseMojo mojo, Command command, ProcessResult result) {
324 File stdout = command.getStdout();
325 if (stdout != null) {
326 write(stdout.getAbsolutePath(), result.getOutput());
327 } else {
328 List<String> lines = result.getOutputLines();
329 if (result.getExitValue() == SUCCESS_CODE) {
330 logInfo(lines);
331 } else {
332 String top = getTop(lines);
333 if (top != null) {
334 logger.info(top);
335 }
336 }
337 }
338 }
339
340 protected void write(String filename, String content) {
341 try {
342 resourceUtils.write(new File(filename), content);
343 } catch (IOException e) {
344 throw new JenkinsException(e);
345 }
346 }
347
348 protected Map<String, String> getBuildParameters(Map<String, String> map, String csv) {
349 Map<String, String> buildParameters = new HashMap<String, String>();
350 if (!Helper.isEmpty(map)) {
351 buildParameters.putAll(map);
352 }
353 if (!StringUtils.isBlank(csv)) {
354 String[] keyValuePairs = Helper.splitAndTrimCSV(csv);
355 Map<String, String> csvMap = Helper.toMap(keyValuePairs);
356 buildParameters.putAll(csvMap);
357 }
358 return buildParameters;
359 }
360
361 protected RunJobCommand getRunJobCommand(RunJobMojo mojo, String jobName, Map<String, String> params) {
362 RunJobCommand rjc = new RunJobCommand();
363 rjc.setName(jobName);
364 rjc.setParams(params);
365 rjc.setCommand(mojo.getCmd());
366 rjc.setWait(mojo.isWait());
367 rjc.setSkipIfNoChanges(mojo.isSkipIfNoChanges());
368 return rjc;
369 }
370
371 public void updateMojo(BaseMojo mojo) {
372 MavenProject project = mojo.getProject();
373 String scmType = extractor.getScmType(project.getScm());
374 String scmUrl = extractor.getScmUrl(project.getScm());
375 String majorVersion = extractor.getMajorVersion(project.getVersion());
376
377 if (StringUtils.isBlank(mojo.getScmType())) {
378 mojo.setScmType(scmType);
379 }
380 if (StringUtils.isBlank(mojo.getScmUrl())) {
381 mojo.setScmUrl(scmUrl);
382 }
383 if (StringUtils.isBlank(mojo.getMajorVersion())) {
384 mojo.setMajorVersion(majorVersion);
385 }
386 }
387
388 public void execute(DeleteJobMojo mojo) {
389 String ignoreCodes = mojo.getIgnoreCodes();
390 String successCodes = mojo.getSuccessCodes();
391 String newSuccessCodes = successCodes + "," + ignoreCodes;
392 mojo.setSuccessCodes(newSuccessCodes);
393 String jobName = getJobName(mojo, mojo.getName());
394 SimpleJobCommand sjc = getSimpleJobCommand(jobName, mojo.getCmd());
395 Command command = new Command();
396 command.setArgs(cmdHelper.toArgs(sjc));
397 executeCli(mojo, command);
398 }
399
400 protected List<SimpleJobCommand> getSimpleJobCommands(List<String> names, String cmd) {
401 List<SimpleJobCommand> commands = new ArrayList<SimpleJobCommand>();
402 for (String name : names) {
403 SimpleJobCommand sjc = getSimpleJobCommand(name, cmd);
404 commands.add(sjc);
405 }
406 return commands;
407 }
408
409 protected SimpleJobCommand getSimpleJobCommand(String name, String cmd) {
410 SimpleJobCommand sjc = new SimpleJobCommand();
411 sjc.setName(name);
412 sjc.setCommand(cmd);
413 return sjc;
414 }
415
416 public void execute(DeleteJobsMojo mojo) {
417 String ignoreCodes = mojo.getIgnoreCodes();
418 String successCodes = mojo.getSuccessCodes();
419 String newSuccessCodes = successCodes + "," + ignoreCodes;
420 mojo.setSuccessCodes(newSuccessCodes);
421 List<String> jobNames = getJobNames(mojo, mojo.getNames(), mojo.getNameList());
422 List<SimpleJobCommand> sjcs = getSimpleJobCommands(jobNames, mojo.getCmd());
423 List<Command> commands = getCommandsFromSimple(sjcs);
424 executeCli(mojo, commands);
425 }
426
427 public void execute(RunJobMojo mojo) {
428 String jobName = getJobName(mojo, mojo.getName());
429 Map<String, String> params = getBuildParameters(mojo.getParamMap(), mojo.getParams());
430 RunJobCommand rjc = getRunJobCommand(mojo, jobName, params);
431 Command command = new Command();
432 command.setArgs(cmdHelper.toArgs(rjc));
433 executeCli(mojo, command);
434 }
435
436 protected void updateCommands(List<RunJobCommand> commands, String cmd, BaseMojo mojo) {
437 for (RunJobCommand command : commands) {
438 String name = getJobName(mojo, command.getName());
439 command.setName(name);
440 command.setCommand(cmd);
441 }
442 }
443
444 protected List<Command> getCommandsFromSimple(List<SimpleJobCommand> sjcs) {
445 List<Command> commands = new ArrayList<Command>();
446 for (SimpleJobCommand sjc : sjcs) {
447 Command command = new Command();
448 command.setArgs(cmdHelper.toArgs(sjc));
449 commands.add(command);
450 }
451 return commands;
452 }
453
454 protected List<Command> getCommands(List<RunJobCommand> rjcs) {
455 List<Command> commands = new ArrayList<Command>();
456 for (RunJobCommand rjc : rjcs) {
457 Command command = new Command();
458 command.setArgs(cmdHelper.toArgs(rjc));
459 commands.add(command);
460 }
461 return commands;
462 }
463
464 public void execute(RunJobsMojo mojo) {
465
466 if (Helper.isEmpty(mojo.getCommands())) {
467 return;
468 }
469 updateCommands(mojo.getCommands(), mojo.getCmd(), mojo);
470 List<Command> commands = getCommands(mojo.getCommands());
471 executeCli(mojo, commands);
472 }
473
474 public void execute(PushJobsMojo mojo) {
475 pushJobs(mojo, mojo.getCmd());
476 }
477
478 public void execute(CliMojo mojo) {
479 List<Command> cmds = cmdHelper.getCommands(mojo);
480 executeCli(mojo, cmds);
481 }
482
483 protected void executeCli(BaseMojo mojo, Command command) {
484 executeCli(mojo, Helper.toList(command));
485 }
486
487 protected void executeCli(BaseMojo mojo, List<Command> commands) {
488 File jar = getJenkinsJar(mojo.getProject(), mojo.getPluginArtifacts());
489 String url = mojo.getUrl();
490 logger.info("Jenkins CLI: " + jar.getPath());
491 logger.info("Jenkins URL: " + url);
492 List<ProcessResult> results = new ArrayList<ProcessResult>();
493 for (Command command : commands) {
494 logger.info(Helper.toString(command.getArgs()));
495 ProcessResult result = executeCli(jar, url, command);
496 handleResult(command, result, mojo);
497 results.add(result);
498 }
499 handleResults(results, mojo);
500 }
501
502 protected void handleResults(List<ProcessResult> results, BaseMojo mojo) {
503 int[] successCodes = getSuccessCodes(mojo);
504 List<ProcessResult> errors = new ArrayList<ProcessResult>();
505 for (ProcessResult result : results) {
506 int exitValue = result.getExitValue();
507 if (!Helper.isMatch(exitValue, successCodes)) {
508 errors.add(result);
509 }
510 }
511 if (errors.size() == 0) {
512 return;
513 }
514 if (mojo.isFailOnError()) {
515 logger.error(getErrorMessage(mojo, errors));
516 throw new JenkinsException("Jenkins CLI error");
517 } else {
518 logger.warn(getWarnMessage(errors));
519 }
520 }
521
522 protected String getWarnMessage(List<ProcessResult> errors) {
523 StringBuilder sb = new StringBuilder();
524 if (errors.size() == 1) {
525 sb.append("There was 1 error.");
526 } else {
527 sb.append("There were " + errors.size() + " errors.");
528 }
529 return sb.toString();
530 }
531
532 protected String getErrorMessage(BaseMojo mojo, List<ProcessResult> errors) {
533 StringBuilder sb = new StringBuilder();
534 if (errors.size() == 1) {
535 sb.append("There was 1 error.");
536 } else {
537 sb.append("There were " + errors.size() + " errors.");
538 }
539 for (ProcessResult result : errors) {
540 sb.append(getErrorMessage(mojo, result));
541 }
542 return sb.toString();
543 }
544
545 protected String getErrorMessage(BaseMojo mojo, ProcessResult result) {
546 ProcessContext context = result.getContext();
547 int exitValue = result.getExitValue();
548 String top = getTop(result.getOutputLines());
549 String[] args = result.getContext().getArgs();
550 String cmd = Helper.toString(args, " ");
551 StringBuilder sb = new StringBuilder();
552 sb.append("\n");
553 sb.append("msg: " + top + "\n");
554 sb.append("executable: " + context.getExecutable() + "\n");
555 sb.append("cmd: " + cmd + "\n");
556 sb.append("result: " + exitValue + "\n");
557 sb.append("input: " + getInputErrorMessage(mojo, context.getInput()) + "\n");
558 if (exitValue != NO_SUCH_COMMAND) {
559 sb.append("details: " + result.getOutput());
560 }
561 return sb.toString();
562 }
563
564 protected String getInputErrorMessage(BaseMojo mojo, String input) {
565 String s = Helper.toEmpty(input);
566 if (StringUtils.isBlank(s)) {
567 return s;
568 }
569 int length = input.length();
570 if (length > 50) {
571 long count = Counter.increment() + 1;
572 File dir = mojo.getWorkingDir();
573 String filename = dir + FS + "error" + FS + "input-" + count + ".log";
574 File file = new File(filename);
575 write(filename, input);
576 return Helper.getRelativePath(mojo.getProject().getBasedir(), file);
577 } else {
578 return input;
579 }
580 }
581
582 public void execute(GenJobsMojo mojo) {
583 List<String> types = Helper.splitAndTrimCSVToList(mojo.getTypes());
584 generateJobs(mojo, types);
585 }
586
587 public void execute(GenJobMojo mojo) {
588 generateJob(mojo, mojo.getType());
589 }
590
591 protected void generateJobs(BaseMojo mojo, List<String> types) {
592 for (String type : types) {
593 generateJob(mojo, type);
594 }
595 }
596
597 protected String getRelativePath(BaseMojo mojo, String filename) {
598 File dir = mojo.getProject().getBasedir();
599 File file = new File(filename);
600 String relativePath = Helper.getRelativePath(dir, file);
601 if (relativePath == null) {
602 return filename;
603 } else {
604 return relativePath;
605 }
606 }
607
608 protected void generateJob(BaseMojo mojo, String type) {
609 try {
610 String jobName = getJobName(mojo, type);
611 String filename = mojo.getWorkingDir() + FS + jobName + XML_EXTENSION;
612 String relativePath = getRelativePath(mojo, filename);
613 mojo.getLog().info("Generating: " + relativePath);
614 Properties properties = getProperties(mojo, type, mojo.getTimestampFormat());
615 String xml = resourceUtils.read(mojo.getTemplate());
616 String resolvedXml = propertiesUtils.getResolvedValue(xml, properties);
617 resourceUtils.write(new File(filename), resolvedXml);
618 } catch (IOException e) {
619 throw new JenkinsException(e);
620 }
621 }
622
623 protected boolean isKnownJobType(BaseMojo mojo, String name) {
624 String jobTypes = mojo.getJobTypes();
625 if (StringUtils.isBlank(jobTypes)) {
626 return false;
627 }
628 if (NONE.equalsIgnoreCase(jobTypes)) {
629 return false;
630 }
631 List<String> jobTypesList = Helper.splitAndTrimCSVToList(mojo.getJobTypes());
632 return jobTypesList.contains(name);
633 }
634
635 protected String getJobName(BaseMojo mojo, String name) {
636 if (isKnownJobType(mojo, name)) {
637 StringBuilder sb = new StringBuilder();
638 sb.append(mojo.getProject().getArtifactId());
639 sb.append(DASH);
640 sb.append(mojo.getMajorVersion());
641 sb.append(DASH);
642 sb.append(name);
643 return sb.toString();
644 } else {
645 return name;
646 }
647 }
648
649 protected Properties getProperties(BaseMojo mojo, String type, String timestampFormat) throws IOException {
650
651 List<String> locations = getLocations(mojo, type);
652 Properties resourceProperties = propertiesUtils.getProperties(locations);
653 Properties jenkinsProperties = getJenkinsProperties(mojo, timestampFormat);
654 Properties projectProperties = mojo.getProject().getProperties();
655 Properties environmentProperties = propertiesUtils.getEnvironmentProperties();
656 Properties systemProperties = System.getProperties();
657
658 Properties properties = new Properties();
659 properties.putAll(resourceProperties);
660 properties.putAll(jenkinsProperties);
661 properties.putAll(projectProperties);
662 properties.putAll(environmentProperties);
663 properties.putAll(systemProperties);
664 return properties;
665 }
666
667 protected Properties getJenkinsProperties(BaseMojo mojo, String timestampFormat) {
668 SimpleDateFormat sdf = new SimpleDateFormat(timestampFormat);
669 Date now = new Date(System.currentTimeMillis());
670 MavenProject project = mojo.getProject();
671 Properties properties = new Properties();
672 properties.setProperty("jenkins.project.scmType", mojo.getScmType());
673 properties.setProperty("jenkins.project.scmUrl", mojo.getScmUrl());
674 properties.setProperty("jenkins.project.majorVersion", mojo.getMajorVersion());
675 properties.setProperty("jenkins.project.groupId", project.getGroupId());
676 properties.setProperty("jenkins.project.artifactId", project.getArtifactId());
677 properties.setProperty("jenkins.build.timestamp", sdf.format(now));
678 return properties;
679 }
680
681 protected List<String> getLocations(BaseMojo mojo, String type) {
682 List<String> locations = new ArrayList<String>();
683 locations.add("classpath:org/kuali/jenkins/jobs/properties/common.xml");
684 locations.add("classpath:org/kuali/jenkins/jobs/properties/" + mojo.getScmType() + XML_EXTENSION);
685 locations.add("classpath:org/kuali/jenkins/jobs/properties/types/" + type + XML_EXTENSION);
686 return locations;
687 }
688
689 }