View Javadoc

1   /*
2    * Copyright 2012 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.ci.maven;
17  
18  import de.smartics.ci.comm.CiController;
19  import de.smartics.ci.comm.command.CommandException;
20  
21  /**
22   * Update job hudson ci mojo.
23   *
24   * @goal updateJob
25   * @requiresProject
26   * @description updates an exiting job within a running hudson server by
27   *              uploading a config.xml.
28   */
29  public class UpdateJobHudsonCiMojo extends AbstractConfigChoiceHudsonCiMojo
30  {
31    // ********************************* Fields *********************************
32  
33    // --- constants ------------------------------------------------------------
34  
35    // --- members --------------------------------------------------------------
36  
37    // ****************************** Initializer *******************************
38  
39    // ****************************** Constructors ******************************
40  
41    // ****************************** Inner Classes *****************************
42  
43    // ********************************* Methods ********************************
44  
45    // --- init -----------------------------------------------------------------
46  
47    // --- get&set --------------------------------------------------------------
48  
49    // --- business -------------------------------------------------------------
50  
51    /**
52     * {@inheritDoc}
53     *
54     * @throws CommandException
55     */
56    public final void executeCommand(final String jobName,
57        final String jobConfigString, final CiController controller)
58      throws CommandException
59    {
60      createJob(jobConfigString, controller, jobName);
61    }
62  
63    private void createJob(final String configString,
64        final CiController controller, final String jobName)
65      throws CommandException
66    {
67      logInfo("Starting to update job: " + jobName);
68      controller.updateJob(jobName, configString);
69      logInfo("Job: " + jobName + " updated");
70    }
71  
72    // --- object basics --------------------------------------------------------
73  
74  }