Standard recommendation is to write your job so that it can correctly clean up the workspace before building, for instance with a git reset or similar. Git scm step has flags for this.
If you want to analyze the workspace upon failure, perhaps use a try/catch block and put an archive step in the catch. On Mon, Feb 1, 2016 at 3:01 PM niristotle okram <[email protected]> wrote: > Yes, i started by thinking that the workspace will be auto unique. i > noticed that when i trigger mulitple build for a job (trying to simulate > the concurrency), it sometime creates workspaces like > > /opt/mount1/jenkins/jobs/GoogleFlow/workspace > > /opt/mount1/jenkins/jobs/GoogleFlow/workspace@2 > > /opt/mount1/jenkins/jobs/GoogleFlow/workspace@3 > > then, the next comes back to > > /opt/mount1/jenkins/jobs/GoogleFlow/workspace > > > > i am not sure why its coming back to this workspace > "/opt/mount1/jenkins/jobs/GoogleFlow/workspace" instead of > "/opt/mount1/jenkins/jobs/GoogleFlow/workspace@4". > > > > My guess is that the first job that was using the > /opt/mount1/jenkins/jobs/GoogleFlow/workspace have moved to the next stage > and the workspace have been allocated to the 4th job in the series. > > > This creates a mess to my job1's file in the same workspace as the job4. The > job4 starts rewriting on them. I have set my workspace to be like so now, so > that each instance of the job uses a specific workspace corresponding to the > BUILD_NUMBER. (Ignore the messy stupid code for the stages) > > > > > > node("master") { > ws("/opt/mount1/jenkins/jobs/GoogleFlow/workspace/${env.BUILD_NUMBER}") { > stage name: 'sync', concurrency: 1 > echo "before sync" > sh '''touch buildFile > echo "This is from ${BUILD_NUMBER}" >> buildFile > cat buildFile''' > sh "sleep 5" > echo "after sync" > sh "date" > > > stage name: 'build_and_test', concurrency: 1 > stage name: 'build' > echo "before build" > sh "date" > sh '''sleep 10 > cat buildFile''' > echo "build 1/3" > sh "sleep 5" > echo "build 2/3" > sh '''sleep 5 > cat buildFile''' > echo "build 3/3" > sh "date" > > stage name: 'test', concurrency: 1 > echo "before test" > sh "date" > sh '''sleep 10 > cat buildFile''' > sh "date" > } > } > > > > I have to decide if i want to delete this workspace after each instance or > leave them for debugging. If left, then find a way to purge them. Am > putting myself in a cobweb now?? :) > > > > > > > > On Mon, Feb 1, 2016 at 2:48 PM, Ryan Campbell <[email protected]> > wrote: > >> Workspaces should already be unique to a given concurrent build of >> Jenkins. You shouldn't have to do anything special to enable this. >> >> On Mon, Feb 1, 2016, 2:38 PM niristotle okram <[email protected]> >> wrote: >> >>> Okay - i figured out the point of error. i should be using the " instead >>> of ' . So it should be >>> >>> ws("/opt/mount1/jenkins/jobs/GoogleFlow/workspace/${env.BUILD_NUMBER}") >>> >>> >>> On Monday, February 1, 2016 at 2:23:10 PM UTC-6, niristotle okram wrote: >>>> >>>> i am trying to create unique workspace for my workflow/pipeline. The >>>> workspace will contain certain files that i don't want to mess up when the >>>> job runs concurrently. my workflow looks something like >>>> >>>> node("master") { >>>> stage name: 'sync', concurrency: 3 >>>> ws('/opt/mount1/jenkins/jobs/GoogleFlow/workspace/(${env.BUILD_NUMBER})') >>>> { >>>> //code block >>>> } >>>> >>>> stage name: 'build_and_test', concurrency: 1 >>>> ws('/opt/mount1/jenkins/jobs/GoogleFlow/workspace/(${env.BUILD_NUMBER})') >>>> { >>>> //code block >>>> } >>>> stage name: 'test', concurrency: 3 >>>> ws('/opt/mount1/jenkins/jobs/GoogleFlow/workspace/(${env.BUILD_NUMBER})') >>>> { >>>> //code block >>>> } >>>> } >>>> >>>> I am expecting jenkins to create workspaces like inside the >>>> main/default workspace (/opt/mount1/jenkins/jobs/GoogleFlow/workspace) as >>>> /opt/mount1/jenkins/jobs/GoogleFlow/workspace/1 >>>> /opt/mount1/jenkins/jobs/GoogleFlow/workspace/2 >>>> /opt/mount1/jenkins/jobs/GoogleFlow/workspace/3 >>>> >>>> >>>> how do i make the env variable ${env.BUILD_NUMBER} get the value while >>>> creating the workspace? >>>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Jenkins Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jenkinsci-users/47c32643-6963-47d2-adf0-c288fe7bda35%40googlegroups.com >>> <https://groups.google.com/d/msgid/jenkinsci-users/47c32643-6963-47d2-adf0-c288fe7bda35%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Jenkins Users" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/jenkinsci-users/i-8gTNug3ck/unsubscribe >> . >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-users/CANHK%3DJ2SFE5TGQ_2r3oXd8mis7%2Bq__JvetXW45--A6dd%2BsbpDA%40mail.gmail.com >> <https://groups.google.com/d/msgid/jenkinsci-users/CANHK%3DJ2SFE5TGQ_2r3oXd8mis7%2Bq__JvetXW45--A6dd%2BsbpDA%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . > > >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Regards > nirish okram > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/CAPzcO4gepXsj%2BG71eGu3DXPm2kimcN0D8w4rx4F9KMN_o99v2w%40mail.gmail.com > <https://groups.google.com/d/msgid/jenkinsci-users/CAPzcO4gepXsj%2BG71eGu3DXPm2kimcN0D8w4rx4F9KMN_o99v2w%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CANHK%3DJ1YPT2p7EGQkqxNaNY8Fdq%2B2xZbXbdpVEP72FJArr2x-g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
