[workflow-plugin] Sharing the workspace between nodes in a workflow

123 views
Skip to first unread message

Sean Flanigan

unread,
Dec 11, 2014, 10:12:23 PM12/11/14
to jenkins...@googlegroups.com
With the workflow plugin, what's a good way of sharing the workspace from one node to another?

The only example I have found is this: https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md#multiple-threads

It uses

    archive 'pom.xml, src/'

on the first node, followed by

    sh 'rm -rf *'
    unarchive mapping: ['pom.xml' : '.', 'src/' : '.']

on the second node.  That should work, but I don't want to explicitly enumerate the files and directories in my workspace, and also I don't want to leave these files clogging up the archive system after the workflow has finished.

If I put the git repo in a subdirectory and archive/unarchive that, it should solve the enumeration problem, but it still leaves me with the disk space problem.  Is there some sort of transient archiving feature I could use?

Alternatively, if I clone the same git repo to both nodes, how can I ensure that they both check out the same git revision?

Sean Flanigan

unread,
Dec 11, 2014, 11:39:13 PM12/11/14
to jenkins...@googlegroups.com
I am using this as a way of getting transient archiving for now:

    def work = 'tmp/'
    try {
      node {
        dir(work) {
          git url: 'g...@github.com:zanata/zanata-parent.git'
          sh 'ls -l'
        }
        archive work
      }
      node {
        sh 'rm -rf -- *'
        unarchive mapping: [(work) : '.']
        dir(work) {
          sh 'ls -l'
          archive '**/pom.xml,**/target/*.jar,**/target/*.war'
        }
      }
    } finally {
      node('master') {
        //def buildNumber = System.getenv()['BUILD_NUMBER']
        sh "rm -rf -- ../builds/*/archive/$work"
      }
    }


I would greatly prefer to delete archive/$work from the current build only (instead of builds/*), but I don't know how to access the build number from the workflow, or whether that even makes sense in a workflow.

If anyone has other ideas or suggestions, please let me know!



--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2f2da7e6-23d1-4ca1-bfda-3cef70b8ebfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jesse Glick

unread,
Jan 8, 2015, 12:49:44 PM1/8/15
to jenkins...@googlegroups.com
On Thursday, December 11, 2014 10:12:23 PM UTC-5, Sean Flanigan wrote:
Alternatively, if I clone the same git repo to both nodes, how can I ensure that they both check out the same git revision?

Reply all
Reply to author
Forward
0 new messages