詹金斯管道突然堕胎

时间:2017-11-22 15:57:21

标签: jenkins cmake jenkins-pipeline jenkins-docker

我正在尝试使用Jenkins Pipeline在docker容器中构建一个cmake项目。

cmake ..命令在中间失败,没有任何错误消息

+ cmake ..
-- The C compiler identification is GNU 7.2.0
-- The CXX compiler identification is GNU 7.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
[Pipeline] }
[Pipeline] // stage

[Pipeline] }

然而,当我在同一个docker容器中手动运行相同的workdir时,一切正常。什么可能是错的,我怎么开始尝试调试这个?请参阅下面的管道脚本

#!groovy
node('agent') {
  currentBuild.description = "${env.GEPARD_PACKAGE}"

  docker.withRegistry("${env.DOCKER_REGISTRY_HOST}") {
    docker.image("gepard-devel-base").inside {

      def gepard_deps
      def build_deps

      stage('Resolve Dependencies') {
        def server = 'http://xxx.local/users/xxx'
        def script = "$server/repos/pipeline/raw/depends\\?at\\=refs%2Fheads%2Fmaster"

        gepard_deps = sh (
          script: "wget $script -O - | bash -s $env.GEPARD_PACKAGE",
          returnStdout: true
        ).trim().split('\n').findAll {pkg -> "${pkg}" != ""} as List<String>

        build_deps = [
          'cmakemodules'
        ] as List<String>

        println build_deps
      }

      stage('Checkout Dependencies') {
        def all_deps = [] as List<String>
        all_deps.addAll(gepard_deps)
        all_deps.addAll(build_deps)
        all_deps.each {
          dir("${it}") {
            git url: "http://xxx/scm/gp/${it}.git"
          }
        }
      }

      stage('Checkout Project') {
        dir("${env.GEPARD_PACKAGE}") {
          git url: "http://xxx/scm/gp/${env.GEPARD_PACKAGE}.git"
        }
      }

      stage('Create Superproject') {
        def proj = "${env.GEPARD_PACKAGE}"
        sh """                                                                                                        
           mkdir -p superproject                                                                                      
           echo 'cmake_minimum_required(VERSION 3.5)'      > superproject/CMakeLists.txt                              
           echo 'project(gepard)'                         >> superproject/CMakeLists.txt                              
           echo 'enable_testing()'                        >> superproject/CMakeLists.txt                              
           echo 'add_subdirectory(../${proj} ${proj})'    >> superproject/CMakeLists.txt                              
        """
        gepard_deps.each {
          sh "echo 'add_subdirectory(../${it} ${it})'     >> superproject/CMakeLists.txt"
        }
      }

      stage('Build GCC') {
        sh """                                                                                                        
           set -e                                                                                                     
           set -x                                                                                                     
            export GEPARD_CMAKE_MODULE_PATH=\$(pwd)/cmakemodules/CMakeGepard                                          
            ls \$GEPARD_CMAKE_MODULE_PATH                                                                             
            pushd superproject                                                                                        
            rm -rf build-gcc && mkdir -p build-gcc                                                                    
            (pushd build-gcc && cmake ..)                                                                             
            (pushd build-gcc && make)                                                                                 
        """
      }

      stage('Done') {
        sh 'echo DONE'
      }
    }
  }
}

0 个答案:

没有答案