Search in sources :

Example 1 with BuildType

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);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) Fields(jetbrains.buildServer.server.rest.model.Fields) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with BuildType

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;
}
Also used : Fields(jetbrains.buildServer.server.rest.model.Fields) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with BuildType

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);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) Fields(jetbrains.buildServer.server.rest.model.Fields) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with BuildType

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);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) Investigations(jetbrains.buildServer.server.rest.model.buildType.Investigations) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Example 5 with BuildType

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);
}
Also used : BuildTypeOrTemplate(jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate) BuildType(jetbrains.buildServer.server.rest.model.buildType.BuildType) Test(org.testng.annotations.Test) ProjectRequestTest(jetbrains.buildServer.server.rest.request.ProjectRequestTest) BaseFinderTest(jetbrains.buildServer.server.rest.data.BaseFinderTest)

Aggregations

BuildType (jetbrains.buildServer.server.rest.model.buildType.BuildType)16 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)14 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)8 ProjectRequestTest (jetbrains.buildServer.server.rest.request.ProjectRequestTest)8 Test (org.testng.annotations.Test)8 ApiOperation (io.swagger.annotations.ApiOperation)7 Fields (jetbrains.buildServer.server.rest.model.Fields)7 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)6 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)6 NotFoundException (jetbrains.buildServer.server.rest.errors.NotFoundException)3 NotNull (org.jetbrains.annotations.NotNull)3 Nullable (org.jetbrains.annotations.Nullable)3 BuildTypes (jetbrains.buildServer.server.rest.model.buildType.BuildTypes)2 Investigations (jetbrains.buildServer.server.rest.model.buildType.Investigations)2 SArtifactDependency (jetbrains.buildServer.serverSide.artifacts.SArtifactDependency)2 SUser (jetbrains.buildServer.users.SUser)2 SVcsRoot (jetbrains.buildServer.vcs.SVcsRoot)2 Logger (com.intellij.openapi.diagnostic.Logger)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1