Search in sources :

Example 6 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_error_to_warning_on_false.

@Test(dataProvider = "supportedBitnessProvider")
public void should_error_to_warning_on_false(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "$res = \"This should be warning\" \nWrite-Error $res");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_LOG_ERR_TO_ERROR, "false");
    getBuildType().setOption(SBuildType.BT_FAIL_ON_ANY_ERROR_MESSAGE, true);
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isSuccessful());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Example 7 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_fail_on_error_output_cmd.

@Test(dataProvider = "supportedBitnessProvider")
public void should_fail_on_error_output_cmd(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_MIN_VERSION, "2.0");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "$res = \"Epic fail\" \nWrite-Error $res");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isFailed());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Example 8 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_pass_explicit_exit_code_cmd.

@Test(dataProvider = "supportedBitnessProvider")
public void should_pass_explicit_exit_code_cmd(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_MIN_VERSION, "2.0");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "$res = \"Test is running\"\nWrite-Output $res\nexit(123)");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isFailed());
    Assert.assertTrue(getBuildLog(build).contains("Process exited with code 123"));
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Example 9 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_fail_on_uncaught_exception_stdin.

@Test(dataProvider = "supportedBitnessProvider")
public void should_fail_on_uncaught_exception_stdin(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_MIN_VERSION, "2.0");
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.STDIN.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "throw \"You shall not pass!\"");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isFailed());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Example 10 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_fail_on_exception_file.

@Test(dataProvider = "supportedBitnessProvider")
public void should_fail_on_exception_file(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "try { \n" + " throw \"You shall not pass!\"" + "} \n" + "Catch\n" + "{\n" + "    $ErrorMessage = $_.Exception.Message\n" + "    Write-Output $ErrorMessage\n" + "    exit(1) \n" + "}");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isFailed());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Aggregations

SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)34 Test (org.testng.annotations.Test)32 TestFor (jetbrains.buildServer.util.TestFor)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)9 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)7 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)7 TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 TestOccurrence (jetbrains.buildServer.server.rest.model.problem.TestOccurrence)3 BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)2 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)2 SkipException (org.testng.SkipException)2 BufferedImage (java.awt.image.BufferedImage)1 SUserGroup (jetbrains.buildServer.groups.SUserGroup)1 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)1 Build (jetbrains.buildServer.server.rest.model.build.Build)1 User (jetbrains.buildServer.server.rest.model.user.User)1 BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)1 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)1