无法添加文件' xxx-dist.tar'到TAR' xxx-dist.tar'在詹金斯

时间:2018-05-16 06:09:48

标签: jenkins publish tar

我在java中编写了一个Web应用程序项目(比如frs)。它由frs-core和frs-ui模块组成。 core由 gradle 构建,ui由 node v9.5.0 工具构建。之后 maven 统一两个模块并转换为TAR格式。但是当它最终想要将它们连接在一起时,会出现以下错误:

The build folder is ready to be deployed. You may serve it with a static server:

  yarn global add serve   serve -s build

Find out more about deployment here:

  http://bitttttttt

:frs-ui:distTar FAILED

FAILURE: Build failed with an exception.

* What went wrong: Execution failed for task ':frs-ui:distTar'.
> Could not add file '/home/samat/workspace/ttbank_frs-2.Build/frs-ui/build/distributions/frs-ui-1.0.0-9dcad410730dbec6f401254f464582e2fa8cd838-build.tar' to TAR '/home/samat/workspace/ttbank_frs-2.Build/frs-ui/build/distributions/frs-ui-1.0.0-9dcad410730dbec6f401254f464582e2fa8cd838-build.tar'.

这是我的 build.gradle 配置

>     group = 'ir.samatco.frs'
>     version = '1.0.0'
> 
>     apply from: "$rootDir/gradle/ci.gradle" }
> 
> ext {
>     javaProjects = [':frs-core', ':frs-gateway'].collect { project it }
>     webProjects = [':frs-ui'].collect { project it } }
> 
> subprojects {
>     if (project in javaProjects) {
>         apply plugin: 'java'
>         sourceCompatibility = 1.7
>         targetCompatibility = 1.7
>         [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
>     }
> 
>     if (project in webProjects) {
>         task npmBuild(type: Exec) {
>             workingDir projectDir
>             executable 'npm'
>             args 'run', 'build'
>         }
>         task distTar(type: Tar) {
>             dependsOn npmBuild
>             baseName = "${project.name}-${project.version}"
>             compression 'gzip'
>             extension 'tar'
>             destinationDir = "$buildDir/distributions" as File
>             from('dist') { into('/') }
>         }
>         idea {
>             module { //                excludeDirs = [".tmp", "bower_components", "dist", "node_modules"].collect {
> file("$projectDir/$it") }
>                 excludeDirs = ["dist", "node_modules"].collect { file("$projectDir/$it") }
>                 sourceDirs = [file("$projectDir/src")]
>             }
>         }
>     }
> 
>     apply plugin: 'maven-publish'
> 
>     publishing {
>         publications {
>             maven(MavenPublication) {
>                 artifact distTar {
>                     classifier 'dist'
>                 }
>             }
>         }
>         repositories {
>             maven() {
>                 credentials {
>                     username project.nexus_user
>                     password project.nexus_pass
>                 }
>                 url "http://nexus.devsamat.ir/content/repositories/test/"
>             }
>         }
>     } }
> 
> task stage {
>     dependsOn subprojects*.publish }

引起的问题" 无法将文件...添加到TAR ... "感谢一个人。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案!故障模块是 frs-ui ,它与build.gradle文件中的 webProject 块有关。所以你应该根据下面改变build.gradle:

if (project in webProjects) {
    task npmBuild(type: Exec) {
        logging.captureStandardOutput LogLevel.INFO
        logging.captureStandardError LogLevel.INFO
        inputs.dir "src"
        outputs.dir "build"
        if(Os.isFamily(Os.FAMILY_WINDOWS)) {
            commandLine 'cmd', '/c', 'npm', 'run', 'build'
        } else {
            commandLine 'npm', 'run', 'build'
        }
    }
    task distTar(type: Tar) {
        dependsOn npmBuild
        baseName = "${project.name}-${project.version}"
        compression 'gzip'
        extension 'tar'
        destinationDir = "$buildDir/distributions" as File
        from('dist') { into('/') }
    }
    idea {
        module {
            excludeDirs = [".tmp", "dist", "node_modules"].collect { file("$projectDir/$it") }
            sourceDirs = [file("$projectDir/src")]
        }
    }
}