Gradle Pitest task works from cmd but fails in Jenkins

273 views Asked by At

I have a gradle script that goes along these lines (some parts were ommited).

buildscript {
    repositories {
        mavenCentral()
        maven { setUrl("https://maven.vaadin.com/vaadin-prereleases") }
        maven { setUrl("https://maven.vaadin.com/vaadin-addons") }
    }
    dependencies {
        classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4'
    }
}


plugins {
    id 'org.springframework.boot' version "$springBootVersion"
    id 'io.spring.dependency-management' version "1.0.14.RELEASE"
    id 'java'
    id 'com.vaadin' version "23.2.4"
    id 'jacoco'
    id 'info.solidsoft.pitest' version '1.7.4'
}

defaultTasks("clean", "build")

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
    maven { setUrl("https://maven.vaadin.com/vaadin-prereleases") }
    maven { setUrl("https://maven.vaadin.com/vaadin-addons") }
}

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

dependencies {
    developmentOnly 'org.springframework.boot:spring-boot-devtools' //faster reloas
    implementation "com.vaadin:vaadin-core:$vaadinVersion"
    implementation "com.vaadin:vaadin:$vaadinVersion"
    implementation group: 'com.vaadin', name: 'vaadin-spring-boot-starter', version: "$vaadinVersion"
    //implementation "com.vaadin:vaadin-spring-boot-starter:$vaadinVersion"
    implementation 'org.vaadin.artur.exampledata:exampledata:3.4.0'
    implementation('com.vaadin:vaadin-spring-boot-starter')

    implementation 'com.h2database:h2:2.1.214'
    implementation "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion"
    implementation "org.springframework.boot:spring-boot-starter-validation:$springBootVersion"
    implementation "org.springframework.boot:spring-boot-starter-security:$springBootVersion"
    implementation "org.springframework.boot:spring-boot-devtools:$springBootVersion"
    implementation enforcedPlatform("com.vaadin:vaadin-bom:$vaadinVersion")

    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: "$junitVersion"
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: "$junitVersion"
    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "$junitVersion"
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
        //implementation "org.springframework.boot:spring-boot-starter-security:$springBootVersion"
    }
    testImplementation "org.springframework.boot:spring-boot-starter-test:$springBootVersion"
    //testImplementation "io.github.bonigarcia:webdrivermanager:3.8.1"
}

dependencyManagement {
    imports {
        mavenBom "com.vaadin:vaadin-bom:$vaadinVersion"
    }
}

test {
    useJUnitPlatform()
    include "**/**/*Test.class"
    finalizedBy jacocoTestReport
}

tasks.withType(JavaCompile) {
    options.deprecation = true
    options.encoding = 'UTF-8'
}

pitest {
    println("Running mutation tests...")
    junit5PluginVersion = '0.15'
    targetClasses = ['com.example.*']  //by default "${project.group}.*"
    pitestVersion = '1.7.4'
    threads = 4
    outputFormats = ['HTML']
    timestampedReports = false
}


configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

When I run gradle pitest from the cmd, I have no problem and the mutation tests are successfully executed.

When I run it from Jenkins, using the following Jenkinsfile, the task fails:

#!/usr/bin/env groovy

pipeline {
    agent any

        stage('Unit Tests') {
            steps {
                script {
                    if (isUnix()) {
                        //Linux Environment
                        sh './gradlew test'
                    }
                    else {
                        //Windows Environment
                        bat './gradlew test'
                    }
                }
            }
        }

        stage('Run mutation tests') {
            steps {
                script {
                    if (isUnix()) {
                        //Linux Environment
                        sh './gradlew pitest'
                    }
                    else {
                        //Windows Environment
                        bat './gradlew pitest'
                    }
                }
            }
        }
    }
}

I cannot find anything related to the error and I cannot understand what the problem might be:

2022-11-01T22:58:48.439+0000 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
2022-11-01T22:58:48.439+0000 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'C:\Program Files\Java\jdk-11.0.9\bin\java.exe'' finished with exit value -1 (state: FAILED)

My Java Version is "11.0.9".

What might be failing in order for this error to happen.

0

There are 0 answers