How to run a maven build command using DSL script in Jenkins - jenkins

I am trying to run a job through DSL script in jenkins. I am new to jenkins. Basically I want to run maven command to run my tests.
How to run maven command using DSL scripts.
Command: mvn test -Dcucumber.options="--tags #registration"
Here is the DSL scripts.But getting error.

Related

Suppress script in the Jenkins post build task

I am using Jenkins Post build task plugin to execute a bash script. The script is running fine, but the entire raw script is printed on the Jenkins console. Check section 3 in the image.
How can I avoid the script from getting printed on the Jenkins console?

Unable to run maven run in GitHub self hosted runner

I created the GitHub Actions self-hosted runner in the Kubernetes cluster with the Maven base image.
But when I am running "mvn clean package" command I am getting "mvn not found error".
Even though I tried giving full maven path still i am getting the same error.
- name: Build with Maven
run: mvn clean package
Maven base image
FROM maven:3.6.0-jdk-11-slim
The error I am getting when I run GitHub Actions.
/runner/_work/_temp/6c9b0c85-4be9-4af0-b168-6dd5bdb998db.sh: line 1: mvn: command not found```

Error with Jenkins executing weblogic.jar

I am using jenkins with windows 10 and weblogic. I created a pipeline to connect git, compile with maven and weblogic deploy. When run the command sh 'java weblogic.WLST script.py' i have the error :
Could not find or load main class weblogic.WLST"
But when a run this command in prompt windows, i dont have problems. I have the environment variables JAVA_HOME and CLASSPATH.
Do I need to configure anything inside the jenkins to use this jar, weblogic.jar?

JUnit tests failing in Jenkins with IllegalStateException

I'm running some JUnit5 tests in Jenkins, using a freestyle job and a Jenkins pipeline. These tests run fine using gradlew locally.
The pipeline groovy script (Jenkinsfile) uses
sh './gradlew clean test'
The code checks out fine and I see the Welcome to Gradle 5.5.1! message
Then, all of the tests which run fine locally with gradlew clean test fail with:
15:50:22
uk.co.motests.mfldirect.tests.UploadDataTest >
dropDownsAreDisplayed() FAILED
15:50:22 java.lang.IllegalStateException
Any idea where / how to start debugging this? This is literally the first time I've tried to run using a groovy pipeline script.
I'm posting this in the hope there is a common, beginners mistake that crops up frequently. I can post further details of the groovy file if required.
To print tests' stdout and stacktrace, enable Gradle INFO logging with sh './gradlew clean test -i'
To view DEBUG logging use sh './gradlew clean test -d'
All this data is already present in ./build/test-results/test/*.xml so you could browse the workspace of the failed Jenkins job.

Jenkins: Running groovy script with ant commands

I have a groovy script with ant commands on it. The script is successfully run in my local machine but when I tried it with Jenkins the groovy script always fail. Jenkins always return error that "ant can't create task or type p4Change". I already added Apache ant support in the global configuration. How do I configure ant to successfully run the groovy script I have. Any idea. Thanks.
Sample code snippets:
I have execute.groovy file with ant commands
ant=new AntBuilder()
def checkChanges {
ant.p4change(description:"Checking",port:'perforce:1666',user:optional,view:"'${workspace}'...")}
And I created a batch file that will run the execute.groovy file
call groovy execute.groovy project bopolz18 -c bopolz18.Workspace 150718
In my machine this works well but in Jenkins when I execute the batch command it fails giving the error mention above.

Resources