Jenkins deploy WAR in glassfish - jenkins

I want deploy in Glassfish a WAR using these batch commands from Jenkins. :
This is how I deploy a WAR with Batch command :
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "undeploy"
Enter the value for the name operand> xxxx
H:\workspace\xxxx>"C:\glassfish3\glassfish\bin\asadmin.bat" "deploy"
Enter the value for the path operand> H:\xxxx-sources\xxxx.war
Application deployed with name xxxx.
Command deploy executed successfully.
In Jenkins , I add a batch command in my build with that :
cd "C:\glassfish3\glassfish\bin\"
asadmin.bat "undeploy"
XXXX
asadmin.bat "deploy"
H:\XXXX sources\XXXX.war
I have this error :
Démarré par l'utilisateur anonymous Building on master in workspace
C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXXCore\workspace
[workspace] $ sh -xe
C:\DOCUME~1\XXXX~1.XXXX\LOCALS~1\Temp\hudson2065869118895930371.sh
The system cannot find the file specified FATAL: L'exécution de la
commande a échoué. java.io.IOException: Cannot run program "sh" (in
directory "C:\Documents and
Settings\XXXX.XXXX.jenkins\jobs\deployerXXXX\workspace"):
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(ProcessBuilder.java:460) at
hudson.Proc$LocalProc.(Proc.java:244) at
hudson.Proc$LocalProc.(Proc.java:216) at
hudson.Launcher$LocalLauncher.launch(Launcher.java:802) at
hudson.Launcher$ProcStarter.start(Launcher.java:380) at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
at
hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at
hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.Build$BuildExecution.build(Build.java:199) at
hudson.model.Build$BuildExecution.doRun(Build.java:160) at
hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
at hudson.model.Run.execute(Run.java:1759) at
hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) at
hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240) Caused by:
java.io.IOException: CreateProcess error=2, The system cannot find the
file specified at java.lang.ProcessImpl.create(Native Method) at
java.lang.ProcessImpl.(ProcessImpl.java:81) at
java.lang.ProcessImpl.start(ProcessImpl.java:30) at
java.lang.ProcessBuilder.start(ProcessBuilder.java:453) ... 15 more
Build step 'Exécuter un script shell' marked build as failure
Finished: FAILURE

It seems that you are trying to execute your scripts in Jenkins using shell script execution,which works only on unix-like systems. Try doing the same with Windows batch execution in the Jenkins job.
You should select 'Execute Windows batch command' according to Jenkins guide.

Related

Git not found deploying .NET web app in azure using jenkins azure app service plugin and pipeline on windows vm

I'm trying to deploy a .NET web app as an app service in Azure using Jenkins and Azure app service plugin. Everything is working fine if I use a free style job and 'publish an azure app' as a post-build action, but I need to perform more complex tasks so I need to use pipeline.
The pipeline is:
stage('checkout') {
git branch: 'develop', url: 'https://github.com/test.git', credentialsId: 'cred'
}
stage('build and publish') {
bat "dotnet publish test/test.sln -c Release "
}
stage('deploy') {
azureWebAppPublish ([
appName: "appName",
azureCredentialsId: params.azure_cred_id,
publishType: "file",
resourceGroup: "resName",
sourceDirectory: "test/test/bin/Release/netcoreapp3.1/publish/"
])
Also tried adding
environment {
git: 'C:\\Program Files\\Git\\cmd\\git.exe'
}
The 'checkout' and 'build and publish' stages work fine, but on 'deploy' stage I get this error:
Starting Azure Web App Deployment
java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
Caused: java.io.IOException: Cannot run program "git" (in directory "c:\jenkins\workspace\test\.azure-deploy"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:252)
at hudson.Proc$LocalProc.<init>(Proc.java:221)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:996)
at hudson.Launcher$ProcStarter.start(Launcher.java:508)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2443)
Caused: hudson.plugins.git.GitException: Error performing git command: git init c:\jenkins\workspace\test\.azure-deploy
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2457)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2380)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2376)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1923)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:995)
The main jenkins is running on linux, but this job is executed on windows node. The configuration is:
Jenkins node configuration
C:\Program Files\Git\cmd is also added in the Environment variables on the VM
I guess I'm missing some additional configuration.

execute groovy script in jenkins job

I am quite new in Jenkins and I am trying to run groovy script 'println "hello world" ' in jenkins. But i am getting below error.
[Test] $ groovy /var/jenkins_home/workspace /Test/hudson481621137087598172.groovy
FATAL: command execution failed
java.io.IOException: Cannot run program "groovy" (in directory "/var/jenkins_home/workspace/Test"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:249)
at hudson.Proc$LocalProc.<init>(Proc.java:218)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:935)
at hudson.Launcher$ProcStarter.start(Launcher.java:454)
at hudson.Launcher$ProcStarter.join(Launcher.java:465)
at hudson.plugins.groovy.Groovy.perform(Groovy.java:106)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1815)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 15 more
Build step 'Execute Groovy script' marked build as failure
Finished: FAILURE
I have found some solution Run groovy scripts in Jenkins but I am not sure how can i use that in my case.
You need to add path to your groovy binaries in Jenkins -> Manage Jenkins -> Global Tool Configuration. Once you install groovy on your machine provide path to it's installation folder. For example on my machine it's like shown on the picture below:
Before checking your Global Tool Configuration in Jenkins, you might try installing/updating your Homebrew installation and run "brew install groovy" first. This will enable you to set the groovy home path (http://macappstore.org/groovy/). Otherwise Jenkins may not save you Tool Configuration properly.
You should set GROOVY_HOME:
export GROOVY_HOME=/usr/local/opt/groovy/libexec

hudson.AbortException: No files found in path with configured filemask: output.xml

I was running a RobotFramework script using Jenkins and everything was working fine until I accidentally wiped out my current workspace. I don't know how to restore it and now I'm getting the following error:
Robot results publisher started...
-Parsing output xml:
Failed!
hudson.AbortException: No files found in path C:\Users\EEMIZHA\.jenkins\jobs\3PI RF2\workspace with configured filemask: output.xml
at hudson.plugins.robot.RobotParser$RobotParserCallable.invoke(RobotParser.java:77)
at hudson.plugins.robot.RobotParser$RobotParserCallable.invoke(RobotParser.java:54)
at hudson.FilePath.act(FilePath.java:990)
at hudson.FilePath.act(FilePath.java:968)
at hudson.plugins.robot.RobotParser.parse(RobotParser.java:49)
at hudson.plugins.robot.RobotPublisher.parse(RobotPublisher.java:217)
at hudson.plugins.robot.RobotPublisher.perform(RobotPublisher.java:239)
at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
at hudson.model.Build$BuildExecution.post2(Build.java:185)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
at hudson.model.Run.execute(Run.java:1763)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Build step 'Publish Robot Framework test results' changed build result to FAILURE
Finished: FAILURE
I have the robot plugin installed, I've enabled a "Publish Robot Framework test results" post build action, and I'm executing a very simple Windows Batch Command as follows:
cd C:\Users\EEMIZHA\Documents\3PIManager\Testing\
pybot jenkinsConnectionTest.robot
Any ideas?
Fixed by using a custom workspace in Jenkins set to my \path\to\test (under Advanced Project Options/Advanced...). Run pybot command with -d \path\to\test\output-folder parameter and set output-folder as "Directory of Robot output" in Robot Framework post build action.

Gatling fails on jenkins when run multiple job on multiple executor

I'm using gatling version 2.1.6 with jenkins plugins annd without maven, my scenario are launch with execute shell
#!/bin/bash
if [ ! -f "novapostme/jenkins/${JOB_NAME}.scala" ]; then
exit 1
fi
${GATLING_HOME}/bin/gatling.sh -df ${WORKSPACE}/novapostme/datas -rf ${WORKSPACE} -sf ${WORKSPACE} -s ${JOB_NAME}
Is each job is run alone on onlly one executor (useing blocking jobs options) all is working well, but when I run multiple job on executors I have sometimes this type of error
[workspace] $ /bin/bash /tmp/hudson6410661655551326741.sh
GATLING_HOME is set to /opt/gatling-charts-highcharts-2.1.6
Exception in thread "main" java.lang.NoClassDefFoundError: MeDocumentDownload
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:71)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at io.gatling.app.classloader.SimulationClassLoader$$anonfun$simulationClasses$1.applyOrElse(SimulationClassLoader.scala:57)
at io.gatling.app.classloader.SimulationClassLoader$$anonfun$simulationClasses$1.applyOrElse(SimulationClassLoader.scala:57)
at scala.collection.immutable.List.collect(List.scala:303)
at io.gatling.app.classloader.SimulationClassLoader.simulationClasses(SimulationClassLoader.scala:57)
at io.gatling.app.Gatling.loadSimulations(Gatling.scala:92)
at io.gatling.app.Gatling.start(Gatling.scala:70)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:59)
at io.gatling.app.Gatling$.main(Gatling.scala:44)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: MeDocumentDownload
at io.gatling.app.classloader.FileSystemBackedClassLoader.findClass(FileSystemBackedClassLoader.scala:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 14 more
Build step 'Execute shell' marked build as failure
Build step 'Groovy Postbuild' marked build as failure
Archiving Gatling reports...
No newer Gatling reports to archive.
Finished: FAILURE
The question is : is it possible to run simultaneous jobs on mutiple executor ?

Jenkins Post Build Task does not work when job is aborted

I have an issue about Post Build Task after an job abort (manual or timeout): the abort generates a java.lang.InterruptedException which seems to be normal. But as Jenkins java machine is stucked how can you run a post task script? I can't.
here is the java exception:
#174 aborted
java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(Native Method)
at hudson.Proc$LocalProc.join(Proc.java:319)
at hudson.Launcher$ProcStarter.join(Launcher.java:345)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:82)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:58)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at
hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:480)
at hudson.model.Run.run(Run.java:1438)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)
Here is my jenkins output:
Build was aborted
Aborted by admin
Performing Post build task...
Match found for :. : True
Logical operation result is TRUE
Running script : dir
[workspace] $ cmd /c call C:\Users\xxxx\AppData\Local
\Temp\2hudson5872719646331136420.bat
Exception when executing the batch command : null
Build step 'Post build task' marked build as failure
Finished: ABORTED
I ran a bat script on the server that copied all hudson****.bat from the folder (which is cleaned after the job) during the job execution/aborting so I've been able to run cmd /c call C:\xxxx\hudson5872719646331136420.bat manually from the windows run, it worked fine.
thanks for your help

Resources