I shutdown jenkins for some purpose. Wonted to launch the jenkins from previous workspace. is there a way to restore the same old jobs?
I am starting jenkins like
java -jar jenkins.war --httpPort=8083 &
But is there a way to provide workspace from commandline?
Workspace is a specific term related to jobs in Jenkins. I think you are looking for JENKINS_HOME. Set the environment variable to the path to the directory that has all your jenkins config and jobs before you start Jenkins.
Related
I have a maven built jar file which could be run as a server. I want to use jenkins-pipeline to deploy this jar file onto my windows 2016 server. I started with a freestyle jenkins job, with "Execute Windows batch" configuration:
set BUILD_ID=DontKillMe
start java -jar MyServer.jar
The java process successfully spawned on my windows 2016 server.
When I turned to use jenkins pipeline script with same batch commands, it's not as expected -- the process which should contain java -jar MyServer.jar was never spawned.
The pipeline script I wrote is:
bat '''
set BUILD_ID=DontKillMe
start java -jar MyServer.jar
'''
The reason I want to have jar starts running in another process is that it could release current jenkins build to following steps.
Could anyone please help with a solution? As long as I can spawn up the java process from batch command in jenkins pipeline (better with no parent process), I would be really grateful.
Ok, seems like jenkins is trying to abandon old jenkins users like me, here's the solution provided by jenkins pipeline:
withEnv(['JENKINS_NODE_COOKIE=DontKillMe']) {
bat "start java -jar MyServer.jar"
}
I am a newbie to the jenkins and trying to run a windows batch job in Jenkins slave. I can see the workspace with all the svn code in job but when am trying to access the command from the workspace folder , i am getting an error path not specified. this is because the Jenkins master is having workspace path as [workspace]/[jobname] where as in slave it is [jobname]/[workspace]. How can i identify the workspace path in jenkins master and run from the slave . please help!
Your not supposed to work on the master. You need to tell which slave your working on with the agent{ label 's1'} block. After, go see the Snippet Generator and check the Checkout function for your svn request.
I am configuring Jenkins for the first time, have been a user of it until now.
I read the documentation and understand what "$WORKSPACE" means on the slave.
I had a misconception that by default the jobs on Jenkins Slave run in a unique directory per job inside the workspace directory. This doesnt seem to be the case.
How do I assign a unique directory per job run?
Will Jenkins automatically cleanup this job run directory after its done?
By default jenkins runs from $WORKSPACE/JOB Name ; here WORKSPACE is defined in the node configuration. This could be changed by choosing Advance Project options -> Use custom workspace under your job configuration.
Regarding cleanup: Choose Build Environment -> Delete workspace before build starts under jobs configuration if you like to cleanup for each new job.
Jenkins will create workspace directory by default if jobs is successfully executed at-least once
I have setup a lot of jobs while Jenkins is running as windows service.When i try to start Jenkins from command line , none of the jobs are showing up.
Can some one let me know how to make sure all jobs are loaded when i start Jenkins from CLI on windows machine.
Make sure you have the same Jenkins home directory when you run it from CLI.
You can use JENKINS_HOME variable to control that:
set JENKINS_HOME=C:/myJenkins
java -jar jenkins.war
I have just added a slave to my Jenkins build - with the idea that I can now deploy artefacts to either my dev server or my test server.
However i've now hit a problem.
When I deploy a job on the master slave, the job build directory is
$JENKINS_HOME/localmoduledirectory (as defined in the build job)
However when I deploy my job via the slave the build directory is different which breaks my jobs. The build directory is
$JENKINS_HOME/workspace/build job title/localmoduledirectory
I know I can change the workspace root directory location for the master under configure settings /advances .. so can change it to $JENKINS_HOME/workspace, but I want to stop the slave using the build job title in the path.
The end result I'm after is to have jenkins, building / deploying from the same location on two servers i.e /opt/jenkins/workspace/localmoduledirectory.
Any ideas ?
ok after lots of head scratching ...
managed to discover that the mvn plugin has a custom workspace option hidden under advanced. so configured all jobs with a customer workspace of /opt/jenkins.