Correct usage of stash\unstash into a different directory

后端 未结 1 1010
离开以前
离开以前 2020-12-14 18:19

In one of my stages I need to copy the contents of two folders after a build is completed and copy to a different directory.

I am actually converting a freestyle job

1条回答
  •  醉梦人生
    2020-12-14 18:25

    I hope it is meant to be this:

    stash includes: 'dist/**/*', name: 'builtSources'
    
    stash includes: 'config/**/*', name: 'appConfig'
    

    where dist and config are the directories in the workspace path, so it should be a relative path like above.

    Rest seems alright, only to mention that path "/some-dir" should be writable by jenkins user (user used to run jenkins daemon).

    And yes it falls back to its then enclosing workspace path (in this case default) when it exits dir block.

    EDIT

    So when you stash a path, it is available to be unstashed at any step later in the pipeline. So yes, you could put dir block under a node('') block.

    You could add something like this :

    stage('Move the Build'){
      node('datahouse'){
        dir('/opt/jenkins_artifacts'){
          unstash 'builtSources'
          unstash 'appConfig'
        }
      }
    }
    

    0 讨论(0)
提交回复
热议问题