詹金斯工作流程藏匿扁平文件夹

时间:2015-12-11 10:43:36

标签: jenkins-workflow

是否可以将一组藏匿的工件作为一个扁平目录解压缩,就像使用jenkins归档一样?

我希望它有3个文件夹藏匿,只有一个文件夹与3的所有内容一起存在,但我目前无法做到。

这是我的尝试:

echo("Workflow Starting...");
node {
  def imageNames = ["connector","registryloader","salepersistence","settlement","standalone","trackingloader"]  
  stage 'Building   
      checkout([$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: '36c9ca9f-de25-4022-b9eb-70ada8e793b8', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: 'http://10.64.111.28/svn/SampleProject/skl-br']], workspaceUpdater: [$class: 'UpdateUpdater']])
      withEnv(["PATH+MAVEN=${tool 'M3'}/bin"]) {
        bat "mvn clean install assembly:assembly versions:resolve-ranges -Dmaven.test.skip=false -DskipTests"
      }
      echo("Archiving")
      archive '**/target/*.tar.gz, conf/desenv/**/*'
      for(int i = 0; i < imageNames.size(); i++){
        String imageName = imageNames[i]
        echo("Stashing ${imageName}")
        stash excludes: '', includes: '**/sklbr-1.0.0-standalone.tar.gz, **/'+imageName+'/*, **/commonConfigs/*, **/scripts/*', name: ''+imageName+''
      }

  stage 'Creating Container'

      docker.withServer('tcp://localhost:2375')
      {
        for(int i = 0; i < imageNames.size(); i++){
          String imageName = imageNames[i]
          ws('sub-workspace ' + imageName) {
            echo("Creating ${imageName} container")
            //unarchive mapping: ['**/sklbr-1.0.0-standalone.tar.gz' : '.', '**/${imageName}/*' : '.', '**/commonConfigs/*' : '.', '**/scripts/*' : '.']
            unstash imageName
            echo("Unstashing ${imageName}")
            def newApp = docker.build "devops-docker-registry:5000/"+imageName+":${env.BUILD_NUMBER}-${env.SVN_REVISION}"
            echo("Building container with ${imageName}")
            newApp.push()
            echo("Pushing ${imageName} container")
          }
        }
      }
} 

2 个答案:

答案 0 :(得分:1)

JENKINS-29780可能会有所帮助,但请记住,您可以将stash和/或unstash包裹在dir中。

答案 1 :(得分:0)

我已经找到了使用shell脚本的方法,但这不是我想要的......

这是为了你需要它

*Nix
sh 'find /${pwd()} -iname "*" -print0 | xargs -0 echo mv -t a'

Windows
bat 'for /r %f in (*) do @move "%f" .'