How to view Jenkins workspace on a Pipeline job?

JenkinsJenkins Pipeline

Jenkins Problem Overview


How can I view Jenkins workspace on a Pipeline job (it was called workflow job previously)? In a standard Job I could just go to the Job main page and view it by clicking on "Workspace".

Jenkins Solutions


Solution 1 - Jenkins

  1. Go to the Jenkins build
  2. On the left hand side click the Pipeline steps
  3. Then on the right click on the link that says "Allocate node : Start - (x min in block)"
  4. On the the left side click the workspace. Done!

The image below might help :

Workspace

Check out this link it shows how to get the workspace when you are using jenkins pipeline: https://www.selikoff.net/2016/07/10/workspace-jenkins-pipelines/

Solution 2 - Jenkins

Pending JENKINS-26138 it is possible albeit inconvenient. Click Pipeline Steps (in older versions, Running Steps) and select the block start for the node (or, rarely, ws) step which created the workspace you are interested in. (Unlike with a freestyle project, there might be zero or several such steps in a given build.) On that step page there will be a Workspace link.

Solution 3 - Jenkins

just add a link using the manager.addShortText and manager.createSummary to the workspace in your pipeline job.

It simple.

if your Job in in a folder the path just changes the Foldername little

node("someslave")
{
    stage("Create workspace link")
    {
        def Foldername = JOB_NAME;          
		def theString = "<a href='https://jenkins.com/job/" + Foldername + "/" + BUILD_NUMBER + "/execution/node/3/ws/'>Workspace</a>";
        manager.addShortText(theString, "blue", "white", "0px", "white");
        manager.createSummary("green.gif").appendText("<h1>" + theString + "</h1>", false, false, false, "blue");
    }
}

Solution 4 - Jenkins

  1. first go to pipeline steps and you will able to see build steps and triggered builds. enter image description here

  2. you can see build id or number whatever you say #89. click on that and you will get below view. enter image description here

  1. now click on work space link.

Solution 5 - Jenkins

Configure custom workspace as follows:

  • Go to Job_Name -> Configure -> Advanced Project Options
  • Enable the checkbox named "Use custom workspace"
  • Fill 'Directory' field relevant to your workspace(absolute path if not exported)

eg: $JENKINS_HOME/Myspace, /home/administrator/Mywork

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRon KeidarView Question on Stackoverflow
Solution 1 - JenkinssamView Answer on Stackoverflow
Solution 2 - JenkinsJesse GlickView Answer on Stackoverflow
Solution 3 - JenkinsSteven FransenView Answer on Stackoverflow
Solution 4 - JenkinsSantosh KadamView Answer on Stackoverflow
Solution 5 - JenkinsBlueView Answer on Stackoverflow