Could not find org.apache.jmeter:bom:5.4.1 - gradle

I have a Jenkinsfile pipeline and in one of its stages I run some jmeter tests and generate the respective report.
This is my stage
stage('Run Non-Functional tests - Windows'){
when { expression { env.OS == 'BAT' }}
steps {
dir('') {
bat 'gradlew.bat jmReport'
}
}
}
and this is my build gradle
import de.qualersoft.jmeter.gradleplugin.task.*
dependencies {
jmeterPlugin("kg.apc:jmeter-plugins-casutg:2.10")
}
plugins {
id "de.qualersoft.jmeter" version "2.1.0"
}
tasks.register('jmRun',JMeterRunTask) {
jmxFile.set("TestPlan.jmx")
}
tasks.register("jmReport",JMeterReportTask) {
jmxFile.set("TestPlan.jmx")
dependsOn("jmRun")
deleteResults=true
}
When I try to run my pipeline it fails with the following error
Execution failed for task ':jmRun'.
> Could not resolve all dependencies for configuration ':jmeterPlugin'.
> Could not find org.apache.jmeter:bom:5.4.1.
Required by:
project :
> Could not find org.apache.jmeter:bom:5.4.1.
Required by:
project : > org.apache.jmeter:ApacheJMeter_core:5.4.1
project : > org.apache.jmeter:ApacheJMeter_core:5.4.1 > org.apache.jmeter:jorphan:5.4.1
Why does this happen? Is it some kind of bug with JMeter?

Take a look at JMeter BugĀ 64465 which contains the workaround.
Or just consider switching to JMeter Maven Plugin

Related

Generate Jacoco report for integration tests

I've created a new test suite called integrationTest using the jvm-test-suite plugin.
Now I want to generate a jacoco report just for the integration tests.
I create a new gradle task like this:
tasks.create<JacocoReport>("jacocoIntegrationTestReport") {
group = "verification"
description = "Generates code coverage report for the integrationTest task."
executionData.setFrom(fileTree(buildDir).include("/jacoco/integrationTest.exec"))
reports {
xml.required.set(true)
html.required.set(true)
}
}
But the generated HTML/XML report is empty. I have run the integration tests before executing the task and the file integrationTest.exec exists.
Thanks
It seems the important part of the new JaCoCo report task configuration is to wire the execution data via the integrationTest task instead of the exec-file path. The official docs (see last example here) also imply that the source set must be wired as well.
Here is the full build script (Gradle 7.6) that produces a report with command:
./gradlew :app:integrationTest :app:jacocoIntegrationTestReport
// build.gradle.kts
plugins {
application
jacoco
}
repositories {
mavenCentral()
}
testing {
suites {
val integrationTest by creating(JvmTestSuite::class) {
dependencies {
implementation(project(":app"))
}
}
}
}
tasks.register<JacocoReport>("jacocoIntegrationTestReport") {
executionData(tasks.named("integrationTest").get())
sourceSets(sourceSets["integrationTest"])
reports {
xml.required.set(true)
html.required.set(true)
}
}

Gradle jacoco plugin: how to print the location of the HTML report at the end of the task execution?

I added the jacoco aggregation plugin to my build
plugins {
id("jacoco-report-aggregation")
}
When I run the task ./gradlew testCodeCoverageReport, the report is correctly generated in build/reports/jacoco/testCodeCoverageReport/html/index.html but it's kinda painful to lookup the file.
How can I simply automate gradle to print the path in the build log?
Here's the solution:
tasks.withType<JacocoReport> {
val reports = reports
doLast {
println("HTML report generated: " + reports.html.entryPoint)
}
}

How to set up a Jenkins pipeline to use a secrets.properties file that isn't committed to GitHub

I have a Springboot/Maven based application that uses a secrets.properties file to store tokens. The file contains a key/value pair as IEX_CLOUD_TOKEN=MY_TOKEN.
After running my Jenkins pipeline, I get the error shown below. It makes sense that it's failing because secrets.properties is not in GitHub. How can I set up the pipeline to use my token when it's needed by the application?
I set up a credential in Jenkins and set it's Kind to Secret file. I then added a withCredentials script to my Jenkinsfile. However, I still get the error message below.
Error Message
context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [edu.bu.cs673.stockportfolio.StockportfolioApplication]; nested exception is java.io.FileNotFoundException: class path resource [secrets.properties] cannot be opened because it does not exist
Jenkinsfile
pipeline {
agent any
triggers {
pollSCM '* * * * *' // 5 stars means poll the scm every minute
}
tools {
maven 'Maven 3.6.3'
}
options {
skipStagesAfterUnstable()
}
environment {
IexCloudApiKey=credentials('IEXCloud')
}
stages {
stage('Test') {
steps {
withCredentials([file(credentialsId: 'IEXCloud', variable: 'FILE')]) {
sh '''
cat $FILE > secrets.properties
mvn test
rm secrets.properties
'''
}
}
}
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
post {
success {
junit 'target/surefire-reports/**/*.xml'
}
}
}
}
}
First several comments about your pipeline.
The pipeline duplicates a lot of steps because you know the life cycle in Maven? If you call mvn compile and afterwards mvn test you will repeat several steps including compile even worse using mvn package also repets several steps...including test and compile so first simplify it to mvn package.
Furthermore you should use a setup for credentials to be done outside the workspace like this:
withCredentials([file(credentialsId: 'secret', variable: 'FILE')]) {
dir('subdir') {
sh 'use $FILE'
}
}

Maven issue while creating Jenkins Pipeline

I am trying to create Jenkins Pipeline for one of my automation job. I created Jenkins file. Code specified below:
pipeline {
agent any
def mvn_version = 'MavenTest'
withEnv( ["PATH+MAVEN=${tool mvn_version}/bin"] ) {
//sh "mvn clean package"
}
stages {
stage('Git checkout') { // for display purposes
steps {
git branch: "ReportTest", url: 'https://github.abc.com/vsing136/testWDM.git'
sh "mvn clean verify"
}
}
stage('Stage 1') {
steps {
echo 'Hello world!'
}
}
}
}
post {
always {
emailext body: "Build URL: ${BUILD_URL}",
subject: "$currentBuild.currentResult-$JOB_NAME",
to: 'vabc1#example.com'
}
}
Screenshot with my job configuration specified below:
I am not sure what am I doing wrong but I am getting error for this configuration -
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 4: Tool type "maven" does not have an install of "Maven 3.3.9" configured - did you mean "Maven"? # line 4, column 11.
maven 'Maven 3.3.9'
^
1 error
Following code worked for me:
agent any
tools {
maven 'MavenTest'
}

Exclude a module or dir or subtask from gradle configuration and execution

I have a task with name test and code is as below :
tasks {
"test"(Test::class) {
useJUnitPlatform {
excludeTags = setOf("e2e", "integration")
}
}
When execute this task with gradle command ./gradlew test --info, gradle is scanning all the modules of my project and generating a configuration with has some tasks from module named data-export-ui-kjs.
I want gradle to exclude the tasks from data-export-ui-kjs module while configuring & executing test task. I have used below code to achieve this but its not successful
gradle.taskGraph.whenReady {
TaskExecutionGraphListener { graph ->
if(it.name.contains("data-export-ui-kjs")) {
it.enabled = false
}
}
}
Kindly help me to get this done. Thanks in advance
Working as expected. Modified the code. Its syntax issue itseems

Resources