Jenkins- trigger a job from one server to another server - jenkins

I am trying to trigger one jenkins job that is on different server.
so, server one has a build job and server2 has deploy job
pipeline {
agent { label 'server2' }
stages {
stage('Build') {
steps {
sh 'curl http://server1:8080/job/DeployJobName/build?token=YOUR_REMOTE_TRIGGER_TOKEN'
}
}
}
}
However, I am getting below error like Cannot run program "nohup".
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)
Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to JNLP4-connect connection from server/10.22.16.15:61442
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1788)
Caused: java.io.IOException: Cannot run program "nohup" (in directory "e:\jenkins\master-019\workspace\BUILD_JOB"): 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)

Related

Run testSuite in katalon using Jenkins throwing "Access denied"

When I build My KatalonTestSuite using Jenkins in windows 10 I am getting below error message.
Started by user Forough Omidvar
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\KatalonTestSuiteRun
[KatalonTestSuiteRun] $ "C:\Program Files\Git\bin" -xe C:\Windows\TEMP\jenkins7833660586059993479.sh
Access is denied
FATAL: command execution failed
java.io.IOException: CreateProcess error=5, Access is denied
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 "C:\Program Files\Git\bin" (in directory "C:\Program Files (x86)\Jenkins\workspace\KatalonTestSuiteRun"): CreateProcess error=5, Access is denied
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:250)
at hudson.Proc$LocalProc.<init>(Proc.java:219)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:937)
at hudson.Launcher$ProcStarter.start(Launcher.java:455)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
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:741)
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:1853)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)
Build step 'Execute shell' marked build as failure
Finished: FAILURE
It seems Jenkin users don’t have the right permission to access the files but I have permission via windows/Security.

XmlPullParserException thrown when trying to run groovy script from within a Jenkins job

I have two Jenkins jobs, one called "UpStreamJob" and the other one is its downstream job called "GetUpstreamJob".
Upstream job is configured to kick-off downstream job as its post build action.
Downstream job is configured with "execute groovy script" option which points to a groovy script
whose main purpose is to get the upstream job name that triggered it and then write the job name to a property file(which I am yet to implement).
Groovy script :
#GrabResolver(name='jenkins', root='http://repo.jenkins-ci.org/public/')
#Grapes([
#Grab(group='org.jenkins-ci.main', module='jenkins-core', version='2.167')
])
import hudson.model.*
def writeToPropertyFile(){
def causes = Run.getCauses()
for (cause in causes)
{
printCausesRecursively(cause)
}
}
def printCausesRecursively(cause) {
if (cause.class.toString().contains("UpstreamCause")) {
println "This job was caused by " + cause.toString()
for (upCause in cause.upstreamCauses) {
printCausesRecursively(upCause)
}
} else {
println "Root cause : " + cause.toString()
}
}
writeToPropertyFile()
The error I get in Jenkins console log is :
Started by upstream project "UpStreamJob" build number 11
originally caused by:
Started by user xyz
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building remotely on Server123 in workspace D:\Jenkins\workspace\GetUpstreamJob
[GetUpstreamJob] $ D:\Jenkins\tools\hudson.plugins.groovy.GroovyInstallation\Groovy-2-5-7\bin\groovy.bat D:\Asif\getUpstreamJob.groovy
Caught: java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at hudson.util.XStream2.getDefaultDriver(XStream2.java:109)
at hudson.util.XStream2.<init>(XStream2.java:113)
at hudson.model.Run.<clinit>(Run.java:2471)
at getUpstreamJob.writeToPropertyFile(getUpstreamJob.groovy:10)
at getUpstreamJob.run(getUpstreamJob.groovy:32)
Caused by: java.lang.ClassNotFoundException: org.xmlpull.v1.XmlPullParserException
... 5 more
Build step 'Execute Groovy script' marked build as failure
Notifying upstream projects of job completion
Finished: FAILURE
EDIT 1 : START
Below is the error that the Jenkins console log shows, when I try running the script by copy-pasting the script's code in the "Execute System Groovy script":
Started by upstream project "UpStreamJob" build number 15
originally caused by:
Started by user Malick, Asif
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building remotely on SERVERNAMEXYZ123 in workspace D:\Jenkins\workspace\GetUpstreamJob
ERROR: Build step failed with exception
groovy.lang.MissingMethodException: No signature of method: java.lang.Class.getCauses() is applicable for argument types: () values: []
Possible solutions: getClasses(), getClass(), getName(), metaClass(groovy.lang.Closure), metaClass(groovy.lang.Closure), getFields()
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:153)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:162)
at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at Script1.writeToPropertyFile(Script1.groovy:10)
at Script1$writeToPropertyFile.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:160)
at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:157)
at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:158)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:162)
at org.kohsuke.groovy.sandbox.impl.Checker$checkedCall.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at Script1.run(Script1.groovy:32)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runScript(GroovySandbox.java:162)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:368)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:312)
at hudson.plugins.groovy.SystemGroovy.run(SystemGroovy.java:95)
at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:59)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
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:1853)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)
Build step 'Execute system Groovy script' marked build as failure
Notifying upstream projects of job completion
Finished: FAILURE
EDIT 2 : END
Please let me know in case I missed out on any details. Part of the logic is taken from the internet.

Stash/unstash causing failure java.io.IOException: Failed to extract MyWar.tar.gz

I want to stash one file from one machine and unstash it to other machine hence I've following pipeline code -
post {
success {
script {
stash allowEmpty: true, includes: 'Installer/My.war', name: 'MyWar', useDefaultExcludes: false
}
node(SERVER1) {
ws("workspace/RedmineAndReviewboardProject/SVNCheckout") {
script {
sh '''mkdir -p "Installer"'''
dir('/Installer') {
unstash 'MyWar'
}
}
}
}
}
}
In this stash code is executed on one machine and unstash on another machine.
But it results into following error -
java.io.IOException: Failed to extract MyWar.tar.gz
at hudson.FilePath.readFromTar(FilePath.java:2608)
at hudson.FilePath.access$500(FilePath.java:211)
at hudson.FilePath$UntarRemote.invoke(FilePath.java:585)
at hudson.FilePath$UntarRemote.invoke(FilePath.java:576)
at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3069)
at hudson.remoting.UserRequest.perform(UserRequest.java:211)
at hudson.remoting.UserRequest.perform(UserRequest.java:54)
at hudson.remoting.Request$2.run(Request.java:369)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to 192.168.136.30
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1741)
at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
at hudson.remoting.Channel.call(Channel.java:955)
at hudson.FilePath.act(FilePath.java:1069)
at hudson.FilePath.act(FilePath.java:1058)
at hudson.FilePath.untar(FilePath.java:571)
at org.jenkinsci.plugins.workflow.flow.StashManager.unstash(StashManager.java:165)
at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:76)
at org.jenkinsci.plugins.workflow.support.steps.stash.UnstashStep$Execution.run(UnstashStep.java:63)
at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
... 4 more
Caused by: java.nio.file.AccessDeniedException: /Installer
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384)
at java.nio.file.Files.createDirectory(Files.java:674)
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781)
at java.nio.file.Files.createDirectories(Files.java:767)
at hudson.FilePath.mkdirs(FilePath.java:3256)
at hudson.FilePath.readFromTar(FilePath.java:2592)
... 12 more
What has gone wrong here?
As #vinWin suggests, your problem seems to be related to accessing the Installer directory.
While on the pipeline you are creating a directory at workspace/RedmineAndReviewboardProject/SVNCheckout/Installer, on the dir command you are trying to access a different one /Installer
On one hand, where you trying to refer to $WORKSPACE on SERVER1 ? If so, on the ws command you should use $WORKSPACE/RedmineAndReviewboardProject/SVNCheckout. Otherwise, your will be working at $WORKSPACE/workspace/RedmineAndReviewboardProject/SVNCheckout
For the dir command, since you are already located at the root of the above defined workspace, using Installer, without the leading / will suffice.

Jenkins - FileName Extensions error

I am using Jenkins for my work where I am trying to JMeter through Jenkins build option to run a batch file, but blocked with the below error.
Started by user admin
Building in workspace D:\
[] $ cmd /c call C:\Users\XXXX\AppData\Local\Temp\hudson4481668363865698547.bat
The filename or extension is too long
FATAL: command execution failed
java.io.IOException: Cannot run program "cmd" (in directory "D:\"): CreateProcess error=206, The filename or extension is too long
at java.lang.ProcessBuilder.start(Unknown Source)
at hudson.Proc$LocalProc.<init>(Proc.java:243)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 16 more
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
I have tried different option of invoking the build but always getting the same error.
Request you to please help in this issue, as I am not able to proceed.

Jenkins launch slave via execution of command on the master + The system cannot find the file specified

Trying to start a slave on a remote machine from Master (local machine) using the Jenkins (launch slave via command line on Master)
ssh 10.1.18.135 java -jar D:/Jenkins/slave.jar
The slave.jar is present in the above path, It fails with this error:
[07/01/13 14:16:11] Launching slave agent $ ssh 10.1.18.135 java -jar
D:/Jenkins/slave.jar The system cannot find the file specified ERROR:
Unable to launch the slave agent for test123 : The system cannot find
the file specified java.io.IOException: Cannot run program "ssh":
CreateProcess error=2, The system cannot find the file specified at
java.lang.ProcessBuilder.start(Unknown Source) at
hudson.slaves.CommandLauncher.launch(CommandLauncher.java:115) at
hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:230) at
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at
java.util.concurrent.FutureTask.run(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source) 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.(Unknown Source) at
java.lang.ProcessImpl.start(Unknown Source)
Can someone help on this?
"The system cannot find the file specified" refers to ssh, not slave.jar. Ensure you have a Windows ssh implementation installed and that the folder it resides in is present in your PATH environment variable.

Resources