Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the jenkins "workspace" a volume from a snapshot #54

Open
wallnerryan opened this issue Sep 15, 2016 · 0 comments
Open

make the jenkins "workspace" a volume from a snapshot #54

wallnerryan opened this issue Sep 15, 2016 · 0 comments

Comments

@wallnerryan
Copy link
Contributor

wallnerryan commented Sep 15, 2016

  • A jenkins workspace is a directory where a build does work
  • Jenkins lets you configure this per slave
  • if a pipeline does work in a workspace, we cannot specify a dpcli volume because we would need jenkins to setup the volume on the slave before calling the build, which would need a tighter integration.
  • since, builds can run in containers,

Inside a node definition in a pipeline we can create a workspace like so.

node('label'){
    //now you are on slave labeled with 'label'
    def workspace = pwd()
    //${workspace} will now contain an absolute path to job workspace on slave 

    // OR

    //now you are on slave labeled with 'label'
    def workspace = $(dpcli create volume --snapshot <snapshot> && dpcli get volume-path)
    //${workspace} will now contain an absolute path to created workspace on the slave
}

This article (https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/chapter-docker-workflow.html) tells us we can use docker args in inside() or better yet we can use docker without the syntax, both are achievable the same way.

Given this, we can do something like the following.

node('label'){
    //now you are on slave labeled with 'label'
    def volume = $(dpcli create volume --snapshot <snapshot> && dpcli get volume-path)
    def workspace = pwd()
    docker.image('httpd').withRun('"-v ${volume}":"${workspace}"' {c ->
        sh "doing something within a FlockerHub Snapshot mapped to the jenkins workspace in a
               container."
   }        
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant