ahh - yes the try/catch is an option that i missed. Now for the delete, i
am referring to the various workspace folder that each run of the
job/workflow is going to create with my current script. My current workflow
script is creating directories with the name as the BUILD_NUMBER as unique
workspace for each run. So, i will end up with lots of directories under "
/opt/mount1/jenkins/jobs/GoogleFlow/workspace"

like

/opt/mount1/jenkins/jobs/GoogleFlow/workspace/1

/opt/mount1/jenkins/jobs/GoogleFlow/workspace/2

/opt/mount1/jenkins/jobs/GoogleFlow/workspace/3

/opt/mount1/jenkins/jobs/GoogleFlow/workspace/4

.

.

.

.

.

.

.


is there any DSL command to delete these workspaces, once the job succeeds?


ws("/opt/mount1/jenkins/jobs/GoogleFlow/workspace/${env.BUILD_NUMBER}")


i see an option "deleteDir()", can i use something like this (at the end of
my workflow)?

*deleteDir("/opt/mount1/jenkins/jobs/GoogleFlow/workspace/${env.BUILD_NUMBER}")*

On Mon, Feb 1, 2016 at 3:13 PM, Ryan Campbell <ryan.campb...@gmail.com>
wrote:

> 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 <nirish.ok...@gmail.com>
> 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 <ryan.campb...@gmail.com>
>> 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 <nirish.ok...@gmail.com>
>>> 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 jenkinsci-users+unsubscr...@googlegroups.com.
>>>> 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
>>> jenkinsci-users+unsubscr...@googlegroups.com.
>>> 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 jenkinsci-users+unsubscr...@googlegroups.com.
>> 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 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
> jenkinsci-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CANHK%3DJ1YPT2p7EGQkqxNaNY8Fdq%2B2xZbXbdpVEP72FJArr2x-g%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CANHK%3DJ1YPT2p7EGQkqxNaNY8Fdq%2B2xZbXbdpVEP72FJArr2x-g%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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAPzcO4hDmaRwEbbdrm_KjcuciaWbTw2i0OP8OgJwhuUOZKPJ9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to