Search in sources :

Example 1 with MavenBuildStep

use of org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep in project acceptance-test-harness by jenkinsci.

the class AbstractAnalysisTest method setMavenGoal.

public void setMavenGoal(final FreeStyleJob job, final String goal) {
    MavenInstallation.ensureThatMavenIsInstalled(jenkins);
    job.configure(() -> {
        MavenBuildStep maven = job.addBuildStep(MavenBuildStep.class);
        maven.setGoals(goal);
        maven.useDefaultMavenVersion();
    });
}
Also used : MavenBuildStep(org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep)

Example 2 with MavenBuildStep

use of org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep in project acceptance-test-harness by jenkinsci.

the class JacocoPluginTest method checkSuccessfulExecutionAndsummary.

@Test
public void checkSuccessfulExecutionAndsummary() {
    MavenInstallation.installSomeMaven(jenkins);
    FreeStyleJob job = jenkins.jobs.create();
    {
        job.copyDir(resource("/jacoco/test"));
        MavenBuildStep maven = job.addBuildStep(MavenBuildStep.class);
        maven.targets.set("clean package -B");
        maven.properties("jacoco.version=" + getJacocoLibraryVersion(), true);
        JacocoPublisher publisher = job.addPublisher(JacocoPublisher.class);
        publisher.changeBuildStatus.check();
    }
    job.save();
    Build build = job.startBuild().waitUntilFinished().shouldSucceed();
    assertThat(build, hasAction("Coverage Report"));
    JacocoResultPage total = new JacocoResultPage(build);
    assertEquals(45.45, total.instructionCoverage(), 0.01);
    assertEquals(50.0, total.branchCoverage(), 0.01);
    assertEquals(33.33, total.complexityScore(), 0.01);
    assertEquals(50.0, total.lineCoverage(), 0.01);
    assertEquals(50.0, total.methodCoverage(), 0.01);
    assertEquals(100.0, total.classCoverage(), 0.01);
    JacocoResultPage pkg = new JacocoResultPage(total, "(default)/App");
    assertEquals(45.45, pkg.instructionCoverage(), 0.01);
    assertEquals(50.0, pkg.branchCoverage(), 0.01);
    assertEquals(33.33, pkg.complexityScore(), 0.01);
    assertEquals(50.0, pkg.lineCoverage(), 0.01);
    assertEquals(50.0, pkg.methodCoverage(), 0.01);
    assertEquals(100.0, pkg.classCoverage(), 0.01);
}
Also used : JacocoResultPage(org.jenkinsci.test.acceptance.plugins.jacoco.JacocoResultPage) JacocoPublisher(org.jenkinsci.test.acceptance.plugins.jacoco.JacocoPublisher) Build(org.jenkinsci.test.acceptance.po.Build) MavenBuildStep(org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test)

Example 3 with MavenBuildStep

use of org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep in project acceptance-test-harness by jenkinsci.

the class JavadocPluginTest method setup.

private void setup(Job job) {
    // https://wiki.jenkins.io/display/JENKINS/Configuring+Content+Security+Policy#ConfiguringContentSecurityPolicy-JavadocPlugin
    jenkins.runScript("System.setProperty('hudson.model.DirectoryBrowserSupport.CSP', \"default-src 'none'; img-src 'self'; style-src 'self'; child-src 'self'; frame-src 'self';\")");
    job.configure();
    MavenBuildStep m = job.addBuildStep(MavenBuildStep.class);
    m.targets.set("archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.mycompany.app -DartifactId=my-app -Dversion=1.0 -B");
    m = job.addBuildStep(MavenBuildStep.class);
    m.targets.set("javadoc:javadoc -f my-app/pom.xml");
    JavadocPublisher jd = job.addPublisher(JavadocPublisher.class);
    jd.javadocDir.set("my-app/target/site/apidocs/");
    job.save();
}
Also used : MavenBuildStep(org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep) JavadocPublisher(org.jenkinsci.test.acceptance.plugins.javadoc.JavadocPublisher)

Example 4 with MavenBuildStep

use of org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep in project acceptance-test-harness by jenkinsci.

the class MavenPluginTest method preserve_backslash_in_property.

@Test
@Issue("JENKINS-10539")
@Since("1.527")
public void preserve_backslash_in_property() {
    installSomeMaven(jenkins);
    FreeStyleJob job = jenkins.jobs.create(FreeStyleJob.class);
    job.configure();
    job.addParameter(StringParameter.class).setName("CMD");
    job.addParameter(StringParameter.class).setName("PROPERTY");
    MavenBuildStep step = job.addBuildStep(MavenBuildStep.class);
    step.targets.set(GENERATE + " -Dcmdline.property=$CMD");
    step.properties("property.property=$PROPERTY", true);
    job.save();
    Map<String, String> params = new HashMap<>();
    params.put("CMD", "\"C:\\\\System\"");
    params.put("PROPERTY", "C:\\Windows");
    job.startBuild(params).shouldSucceed().shouldContainsConsoleOutput("cmdline.property=C:\\\\System").shouldContainsConsoleOutput("property.property=C:\\\\Windows");
}
Also used : StringParameter(org.jenkinsci.test.acceptance.po.StringParameter) HashMap(java.util.HashMap) MavenBuildStep(org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) Issue(org.jvnet.hudson.test.Issue) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest) Since(org.jenkinsci.test.acceptance.junit.Since)

Example 5 with MavenBuildStep

use of org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep in project acceptance-test-harness by jenkinsci.

the class MavenPluginTest method autoinstall_maven_for_freestyle_job.

@Test
public void autoinstall_maven_for_freestyle_job() {
    installMaven(jenkins, "maven_3.6.3", "3.6.3");
    FreeStyleJob job = jenkins.jobs.create();
    job.configure();
    MavenBuildStep step = job.addBuildStep(MavenBuildStep.class);
    step.version.select("maven_3.6.3");
    step.targets.set("-version");
    job.save();
    job.startBuild().shouldSucceed().shouldContainsConsoleOutput("Apache Maven 3.6.3");
}
Also used : MavenBuildStep(org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep) FreeStyleJob(org.jenkinsci.test.acceptance.po.FreeStyleJob) AbstractJUnitTest(org.jenkinsci.test.acceptance.junit.AbstractJUnitTest) Test(org.junit.Test) DockerTest(org.jenkinsci.test.acceptance.junit.DockerTest)

Aggregations

MavenBuildStep (org.jenkinsci.test.acceptance.plugins.maven.MavenBuildStep)9 AbstractJUnitTest (org.jenkinsci.test.acceptance.junit.AbstractJUnitTest)7 Test (org.junit.Test)7 FreeStyleJob (org.jenkinsci.test.acceptance.po.FreeStyleJob)6 DockerTest (org.jenkinsci.test.acceptance.junit.DockerTest)4 Build (org.jenkinsci.test.acceptance.po.Build)2 HashMap (java.util.HashMap)1 Since (org.jenkinsci.test.acceptance.junit.Since)1 EmmaPublisher (org.jenkinsci.test.acceptance.plugins.emma.EmmaPublisher)1 EmmaResultsPage (org.jenkinsci.test.acceptance.plugins.emma.EmmaResultsPage)1 JacocoPublisher (org.jenkinsci.test.acceptance.plugins.jacoco.JacocoPublisher)1 JacocoResultPage (org.jenkinsci.test.acceptance.plugins.jacoco.JacocoResultPage)1 JavadocPublisher (org.jenkinsci.test.acceptance.plugins.javadoc.JavadocPublisher)1 StringParameter (org.jenkinsci.test.acceptance.po.StringParameter)1 Issue (org.jvnet.hudson.test.Issue)1