use of jetbrains.buildServer.server.rest.model.buildType.BuildType in project teamcity-rest by JetBrains.
the class ProjectRequest method createEmptyBuildType.
@POST
@Path("/{projectLocator}/buildTypes")
@Produces({ "application/xml", "application/json" })
@Consumes({ "text/plain" })
@ApiOperation(hidden = true, value = "Use createBuildType instead")
public BuildType createEmptyBuildType(@ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, String name, @QueryParam("fields") String fields) {
SProject project = myProjectFinder.getItem(projectLocator);
if (StringUtil.isEmpty(name)) {
throw new BadRequestException("Build type name cannot be empty.");
}
final SBuildType buildType = project.createBuildType(name);
buildType.schedulePersisting("A new build configuration is created");
return new BuildType(new BuildTypeOrTemplate(buildType), new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.model.buildType.BuildType in project teamcity-rest by JetBrains.
the class ProjectRequest method getDefaultTemplate.
@GET
@Path("/{projectLocator}/defaultTemplate")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Get the default template of the matching project.", nickname = "getDefaultTemplate")
public BuildType getDefaultTemplate(@ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, @QueryParam("fields") String fields) {
SProject project = myProjectFinder.getItem(projectLocator, true);
BuildType result = Project.getDefaultTemplate(project, new Fields(fields), myBeanContext);
if (result == null)
throw new NotFoundException("No default template present");
return result;
}
use of jetbrains.buildServer.server.rest.model.buildType.BuildType in project teamcity-rest by JetBrains.
the class ProjectRequest method createEmptyBuildTypeTemplate.
@POST
@Path("/{projectLocator}/templates")
@Produces({ "application/xml", "application/json" })
@Consumes({ "text/plain" })
@ApiOperation(hidden = true, value = "Use createBuildTypeTemplate instead")
public BuildType createEmptyBuildTypeTemplate(@ApiParam(format = LocatorName.PROJECT) @PathParam("projectLocator") String projectLocator, String name, @QueryParam("fields") String fields) {
SProject project = myProjectFinder.getItem(projectLocator, true);
if (StringUtil.isEmpty(name)) {
throw new BadRequestException("Build type template name cannot be empty.");
}
final BuildTypeTemplate buildType = project.createBuildTypeTemplate(name);
buildType.schedulePersisting("A new build configuration template is created");
return new BuildType(new BuildTypeOrTemplate(buildType), new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.server.rest.model.buildType.BuildType in project teamcity-rest by JetBrains.
the class BuildTypeTest method testSimple.
@Test
public void testSimple() {
final BuildTypeEx bt = getRootProject().createProject("Project1", "Project test 1").createBuildType("testBT", "My test build type");
final BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt), Fields.LONG, myBeanContext);
assertEquals(bt.getName(), buildType.getName());
assertEquals(bt.getProjectExternalId(), buildType.getProjectId());
assertEquals(bt.getProjectName(), buildType.getProjectName());
assertEquals(new Integer(0), buildType.getParameters().count);
final Investigations investigations = buildType.getInvestigations();
assertEquals(null, investigations.count);
assertEquals("/app/rest/investigations?locator=buildType:(id:testBT)", investigations.href);
}
use of jetbrains.buildServer.server.rest.model.buildType.BuildType in project teamcity-rest by JetBrains.
the class BuildTypeTest method testLinks.
@Test
public void testLinks() {
final BuildTypeEx bt = getRootProject().createProject("Project1", "Project test 1").createBuildType("testBT", "My test build type");
WebLinks webLinks = getWebLinks(myServer.getRootUrl());
RelativeWebLinks relativeWebLinks = new RelativeWebLinks();
assertEquals("http://localhost/viewType.html?buildTypeId=testBT", webLinks.getConfigurationHomePageUrl(bt));
assertEquals("/viewType.html?buildTypeId=testBT", relativeWebLinks.getConfigurationHomePageUrl(bt));
BuildType buildType = new BuildType(new BuildTypeOrTemplate(bt), Fields.SHORT, myBeanContext);
assertEquals(webLinks.getConfigurationHomePageUrl(bt), buildType.getWebUrl());
assertNull(buildType.getLinks());
buildType = new BuildType(new BuildTypeOrTemplate(bt), Fields.LONG, myBeanContext);
assertEquals(webLinks.getConfigurationHomePageUrl(bt), buildType.getWebUrl());
// not present until explicitly requested
assertNull(buildType.getLinks());
buildType = new BuildType(new BuildTypeOrTemplate(bt), new Fields("links"), myBeanContext);
assertNotNull(buildType.getLinks());
assertEquals(Integer.valueOf(2), buildType.getLinks().count);
assertNotNull(buildType.getLinks().links);
assertEquals("webView", buildType.getLinks().links.get(0).type);
assertEquals(webLinks.getConfigurationHomePageUrl(bt), buildType.getLinks().links.get(0).url);
assertEquals(relativeWebLinks.getConfigurationHomePageUrl(bt), buildType.getLinks().links.get(0).relativeUrl);
assertEquals("webEdit", buildType.getLinks().links.get(1).type);
assertEquals(webLinks.getEditConfigurationPageUrl(bt.getExternalId()), buildType.getLinks().links.get(1).url);
assertEquals(relativeWebLinks.getEditConfigurationPageUrl(bt.getExternalId()), buildType.getLinks().links.get(1).relativeUrl);
}
Aggregations