Change Jenkins job workspace

18,207

Solution 1

Under "Advanced" you can explicitly choose a working directory for the projects without changing the Jenkins home directory. Check the "Use custom workspace" box and set the directory that Jenkins will pull the code to and build in.

In our setup we wait for the build process to complete in the working directory and add a build step for Jenkins to copy (most) of the files out to the directory that serves up the website. We had issues with file locking preventing the build process if someone (e.g. the testers) were using the site.

Solution 2

One simple way to do it is to create a symlink under /var/www/html/ that points to your code directory, e.g.:

sudo ln -s /var/lib/jenkins/jobs/"Code Deployement" /var/www/html/[project-name]
Share:
18,207
Nishant Jani
Author by

Nishant Jani

Updated on June 04, 2022

Comments

  • Nishant Jani
    Nishant Jani about 2 years

    What I have done :

    I have Jenkins set up on my Ubuntu in :

    /var/lib/jenkins/

    I have a job, that runs every 45 minutes that does a hg pull and hg update --clean default from my bitbucket repository.So this is running fine.I have a folder

    /var/lib/jenkins/jobs/Code Deployement

    which contains the latest updated code from my repository.

    Problem :

    However, I want to access my updated code from

    /var/www/html/[project-name]

    Query :

    Is there anyway i can make jenkins job update this folder instead of the /var/lib/jenkins/Code Deployment folder ? I certainly dont want to make /var/www/html/[project-name] as my jenkins home folder.

    How can I achieve what I described above.Will I have to copy the folder from the jobs folder to my desired location after every time the job runs ? Please help me out with the solution,I'am a beginner with automated deployment using Jenkins.

    Thank you.