org.sonar.plugins.buildstability.ci.bamboo.BambooServer Maven / Gradle / Ivy
/*
* Sonar Build Stability Plugin
* Copyright (C) 2010 SonarSource
* [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonar.plugins.buildstability.ci.bamboo;
import org.sonar.plugins.buildstability.ci.api.Build;
import org.sonar.api.utils.SonarException;
import org.sonar.plugins.buildstability.ci.api.AbstractServer;
import org.sonar.plugins.buildstability.ci.api.Unmarshaller;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
/**
* See Bamboo REST APIs.
*
* @author Evgeny Mandrikov
*/
public class BambooServer extends AbstractServer {
public static final String SYSTEM = "Bamboo";
public static final String PATTERN = "/browse/";
private static final Unmarshaller BUILD_UNMARSHALLER = new BambooBuildUnmarshaller();
public String getBuildUrl(String number) {
StringBuilder sb = new StringBuilder(getHost())
.append("/rest/api/latest/result/").append(getKey()).append("/").append(number)
.append("?os_authType=basic")
.append("&expand=results.result");
return sb.toString();
}
@Override
public String getLastBuildUrl() {
try {
StringBuilder sb = new StringBuilder(getHost())
.append("/rest/api/latest/result/").append(getKey())
.append("?os_authType=basic")
.append("&expand=results").append(URLEncoder.encode("[0]", "UTF-8")).append(".result");
return sb.toString();
} catch (UnsupportedEncodingException e) {
throw new SonarException(e);
}
}
@Override
public Unmarshaller getBuildUnmarshaller() {
return BUILD_UNMARSHALLER;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy