View Javadoc
1   /*
2    * The MIT License (MIT)
3    *
4    * Copyright (c) 2013-2026 The Coveralls Maven Plugin Project Contributors:
5    *     https://github.com/hazendaz/coveralls-maven-plugin/graphs/contributors
6    *
7    * Permission is hereby granted, free of charge, to any person obtaining a copy
8    * of this software and associated documentation files (the "Software"), to deal
9    * in the Software without restriction, including without limitation the rights
10   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11   * copies of the Software, and to permit persons to whom the Software is
12   * furnished to do so, subject to the following conditions:
13   *
14   * The above copyright notice and this permission notice shall be included in
15   * all copies or substantial portions of the Software.
16   *
17   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23   * THE SOFTWARE.
24   */
25  package org.eluder.coveralls.maven.plugin.service;
26  
27  import java.util.Map;
28  import java.util.Properties;
29  
30  /**
31   * Service implementation for Appveyor.
32   * <p>
33   * https://appveyor.com/
34   */
35  public class Appveyor extends AbstractServiceSetup {
36  
37      /** The Constant APPVEYOR_NAME. */
38      public static final String APPVEYOR_NAME = "Appveyor";
39  
40      /** The Constant APPVEYOR. */
41      public static final String APPVEYOR = "APPVEYOR";
42  
43      /** The Constant APPVEYOR_BUILD_NUMBER. */
44      public static final String APPVEYOR_BUILD_NUMBER = "APPVEYOR_BUILD_NUMBER";
45  
46      /** The Constant APPVEYOR_BUILD_ID. */
47      public static final String APPVEYOR_BUILD_ID = "APPVEYOR_BUILD_ID";
48  
49      /** The Constant APPVEYOR_BRANCH. */
50      public static final String APPVEYOR_BRANCH = "APPVEYOR_REPO_BRANCH";
51  
52      /** The Constant APPVEYOR_COMMIT. */
53      public static final String APPVEYOR_COMMIT = "APPVEYOR_REPO_COMMIT";
54  
55      /** The Constant APPVEYOR_PULL_REQUEST. */
56      public static final String APPVEYOR_PULL_REQUEST = "APPVEYOR_PULL_REQUEST_NUMBER";
57  
58      /** The Constant APPVEYOR_REPO_NAME. */
59      public static final String APPVEYOR_REPO_NAME = "APPVEYOR_REPO_NAME";
60  
61      /**
62       * Instantiates a new appveyor.
63       *
64       * @param env
65       *            the env
66       */
67      public Appveyor(final Map<String, String> env) {
68          super(env);
69      }
70  
71      @Override
72      public boolean isSelected() {
73          return Boolean.parseBoolean(this.getProperty(Appveyor.APPVEYOR));
74      }
75  
76      @Override
77      public String getName() {
78          return Appveyor.APPVEYOR_NAME;
79      }
80  
81      @Override
82      public String getBuildNumber() {
83          return this.getProperty(Appveyor.APPVEYOR_BUILD_NUMBER);
84      }
85  
86      @Override
87      public String getBuildUrl() {
88          return "https://ci.appveyor.com/project/" + this.getProperty(Appveyor.APPVEYOR_REPO_NAME) + "/build/"
89                  + this.getProperty(Appveyor.APPVEYOR_BUILD_NUMBER);
90      }
91  
92      @Override
93      public String getBranch() {
94          return this.getProperty(Appveyor.APPVEYOR_BRANCH);
95      }
96  
97      @Override
98      public String getPullRequest() {
99          return this.getProperty(Appveyor.APPVEYOR_PULL_REQUEST);
100     }
101 
102     @Override
103     public String getJobId() {
104         return this.getProperty(Appveyor.APPVEYOR_BUILD_ID);
105     }
106 
107     @Override
108     public Properties getEnvironment() {
109         final var environment = new Properties();
110         this.addProperty(environment, "appveyor_build_id", this.getProperty(Appveyor.APPVEYOR_BUILD_ID));
111         this.addProperty(environment, "appveyor_build_number", this.getProperty(Appveyor.APPVEYOR_BUILD_NUMBER));
112         this.addProperty(environment, "appveyor_repo_name", this.getProperty(Appveyor.APPVEYOR_REPO_NAME));
113         this.addProperty(environment, "appveyor_branch", this.getProperty(Appveyor.APPVEYOR_BRANCH));
114         this.addProperty(environment, "appveyor_commit", this.getProperty(Appveyor.APPVEYOR_COMMIT));
115         this.addProperty(environment, "appveyor_pull_request", this.getProperty(Appveyor.APPVEYOR_PULL_REQUEST));
116         return environment;
117     }
118 
119 }