Search in sources :

Example 1 with BuildListener

use of hudson.model.BuildListener in project blueocean-plugin by jenkinsci.

the class PipelineApiTest method testArtifactsRunApi.

@Test
public void testArtifactsRunApi() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject("pipeline1");
    p.getBuildersList().add(new TestBuilder() {

        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            FilePath ws = build.getWorkspace();
            if (ws == null) {
                return false;
            }
            FilePath dir = ws.child("dir");
            dir.mkdirs();
            dir.child("fizz").write("contents", null);
            dir.child("lodge").symlinkTo("fizz", listener);
            return true;
        }
    });
    ArtifactArchiver aa = new ArtifactArchiver("dir/fizz");
    aa.setAllowEmptyArchive(true);
    p.getPublishersList().add(aa);
    FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
    List artifacts = get("/organizations/jenkins/pipelines/pipeline1/runs/" + b.getId() + "/artifacts", List.class);
    assertEquals(1, artifacts.size());
    assertEquals("fizz", ((Map) artifacts.get(0)).get("name"));
}
Also used : FilePath(hudson.FilePath) BuildListener(hudson.model.BuildListener) ArtifactArchiver(hudson.tasks.ArtifactArchiver) Launcher(hudson.Launcher) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) FreeStyleBuild(hudson.model.FreeStyleBuild) FreeStyleProject(hudson.model.FreeStyleProject) TestBuilder(org.jvnet.hudson.test.TestBuilder) Test(org.junit.Test)

Example 2 with BuildListener

use of hudson.model.BuildListener in project violations-plugin by jenkinsci.

the class ViolationsReportBuilder method perform.

public ViolationsReportAsserter perform() throws Exception {
    ViolationsConfig config = new ViolationsConfig();
    config.setSourcePathPattern(sourcePathPattern);
    TypeConfig typeConfig = new TypeConfig(typeDescriptor.getName());
    typeConfig.setPattern(sourcePathPattern);
    config.getTypeConfigs().put(typeDescriptor.getName(), typeConfig);
    FilePath workspace = new FilePath(projectRootDir());
    FilePath targetPath = new FilePath(new File(projectRootDir().getPath() + "/" + VIOLATIONS));
    FilePath htmlPath = new FilePath(projectRootDir());
    AbstractBuild<?, ?> build = mock(Build.class);
    when(build.getRootDir()).thenReturn(projectRootDir());
    BuildListener listener = mock(BuildListener.class);
    ViolationsReport violationsReport = createBuildAction(workspace, targetPath, htmlPath, config, build, listener).getReport();
    return assertThat(violationsReport, typeDescriptor);
}
Also used : FilePath(hudson.FilePath) BuildListener(hudson.model.BuildListener) File(java.io.File)

Example 3 with BuildListener

use of hudson.model.BuildListener in project violations-plugin by jenkinsci.

the class RatchetingTest method testThatMinIsUpdatedIfMaxIsLessThenMinCanBeUpdated.

@Test
public void testThatMinIsUpdatedIfMaxIsLessThenMinCanBeUpdated() {
    BuildListener listener = mock(BuildListener.class);
    when(listener.getLogger()).thenReturn(out);
    Collection<TypeReport> typeReports = newArrayList(type(CHECKSTYLE, 7));
    ViolationsConfig config = new ViolationsConfig();
    config.setAutoUpdateMax(TRUE);
    config.getTypeConfigs().get(CHECKSTYLE).setMax(15);
    config.getTypeConfigs().get(CHECKSTYLE).setMin(9);
    handleRatcheting(SUCCESS, typeReports, listener, config);
    assertEquals("Expected ratcheting to have been updated", 8, config.getTypeConfigs().get(CHECKSTYLE).getMax());
    assertEquals("Expected ratcheting to have been updated", 7, config.getTypeConfigs().get(CHECKSTYLE).getMin());
}
Also used : BuildListener(hudson.model.BuildListener) TypeReport(hudson.plugins.violations.ViolationsReport.TypeReport) Test(org.junit.Test)

Example 4 with BuildListener

use of hudson.model.BuildListener in project violations-plugin by jenkinsci.

the class RatchetingTest method testThatUnstableLimitCanBeUpdated.

@Test
public void testThatUnstableLimitCanBeUpdated() {
    BuildListener listener = mock(BuildListener.class);
    when(listener.getLogger()).thenReturn(out);
    Collection<TypeReport> typeReports = newArrayList(type(CHECKSTYLE, 1));
    ViolationsConfig config = new ViolationsConfig();
    config.setAutoUpdateUnstable(TRUE);
    config.getTypeConfigs().get(CHECKSTYLE).setUnstable(4);
    handleRatcheting(SUCCESS, typeReports, listener, config);
    assertEquals("Expected ratcheting to have been updated", 2, config.getTypeConfigs().get(CHECKSTYLE).getUnstable().intValue());
}
Also used : BuildListener(hudson.model.BuildListener) TypeReport(hudson.plugins.violations.ViolationsReport.TypeReport) Test(org.junit.Test)

Example 5 with BuildListener

use of hudson.model.BuildListener in project violations-plugin by jenkinsci.

the class RatchetingTest method testThatMaxCanBeUpdated.

@Test
public void testThatMaxCanBeUpdated() {
    BuildListener listener = mock(BuildListener.class);
    when(listener.getLogger()).thenReturn(out);
    Collection<TypeReport> typeReports = newArrayList(type(CHECKSTYLE, 7));
    ViolationsConfig config = new ViolationsConfig();
    config.setAutoUpdateMax(TRUE);
    config.getTypeConfigs().get(CHECKSTYLE).setMax(15);
    handleRatcheting(SUCCESS, typeReports, listener, config);
    assertEquals("Expected ratcheting to have been updated", 8, config.getTypeConfigs().get(CHECKSTYLE).getMax());
}
Also used : BuildListener(hudson.model.BuildListener) TypeReport(hudson.plugins.violations.ViolationsReport.TypeReport) Test(org.junit.Test)

Aggregations

BuildListener (hudson.model.BuildListener)5 Test (org.junit.Test)4 TypeReport (hudson.plugins.violations.ViolationsReport.TypeReport)3 FilePath (hudson.FilePath)2 ImmutableList (com.google.common.collect.ImmutableList)1 Launcher (hudson.Launcher)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 FreeStyleProject (hudson.model.FreeStyleProject)1 ArtifactArchiver (hudson.tasks.ArtifactArchiver)1 File (java.io.File)1 IOException (java.io.IOException)1 List (java.util.List)1 TestBuilder (org.jvnet.hudson.test.TestBuilder)1