Jenkinsfile 3.2 KB
Newer Older
L
liuyq-617 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
import hudson.model.Result
import jenkins.model.CauseOfInterruption
properties([pipelineTriggers([githubPush()])])
node {
    git url: 'https://github.com/taosdata/TDengine.git'
}


def abortPreviousBuilds() {
  def currentJobName = env.JOB_NAME
  def currentBuildNumber = env.BUILD_NUMBER.toInteger()
  def jobs = Jenkins.instance.getItemByFullName(currentJobName)
  def builds = jobs.getBuilds()

  for (build in builds) {
    if (!build.isBuilding()) {
      continue;
    }

    if (currentBuildNumber == build.getNumber().toInteger()) {
      continue;
    }

    build.doKill()    //doTerm(),doKill(),doTerm()
  }
}
//停止之前相同的分支。。
abortPreviousBuilds()

L
liuyq-617 已提交
30 31 32 33 34 35 36
def pre_test(){
    catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                sh '''
                sudo rmtaos
                '''
    }
    sh '''
L
liuyq-617 已提交
37
    
L
liuyq-617 已提交
38
    cd ${WKC}
L
liuyq-617 已提交
39
    rm -rf *
L
liuyq-617 已提交
40
    cd ${WK}
41
    git reset --hard
L
liuyq-617 已提交
42
    git checkout develop
43
    git pull
L
liuyq-617 已提交
44 45 46 47
    cd ${WKC}
    rm -rf *
    mv ${WORKSPACE}/* .
    cd ${WK}
L
liuyq-617 已提交
48 49 50 51 52 53 54 55
    export TZ=Asia/Harbin
    date
    rm -rf ${WK}/debug
    mkdir debug
    cd debug
    cmake .. > /dev/null
    make > /dev/null
    make install > /dev/null
L
liuyq-617 已提交
56
    cd ${WKC}/tests
L
liuyq-617 已提交
57 58 59 60 61
    '''
    return 1
}
pipeline {
  agent none
L
liuyq-617 已提交
62
  
L
liuyq-617 已提交
63 64 65 66
  environment{
      WK = '/var/lib/jenkins/workspace/TDinternal'
      WKC= '/var/lib/jenkins/workspace/TDinternal/community'
  }
L
liuyq-617 已提交
67
  
L
liuyq-617 已提交
68
  stages {
L
liuyq-617 已提交
69 70
      
    
L
liuyq-617 已提交
71
      stage('Parallel test stage') {
L
liuyq-617 已提交
72 73 74 75
          //only pr triggering the build.
        when {
              changeRequest()
          }
L
liuyq-617 已提交
76
      parallel {
L
liuyq-617 已提交
77 78 79
        stage('python') {             
          agent{label 'pytest'}
          steps {            
L
liuyq-617 已提交
80 81 82
            pre_test()
            sh '''
            cd ${WKC}/tests
83
            ./test-all.sh pytest
L
liuyq-617 已提交
84 85 86 87
            date'''
          }
        }
        stage('test_b1') {
L
liuyq-617 已提交
88 89
          agent{label 'b1'}
          steps {            
L
liuyq-617 已提交
90 91 92 93 94 95 96
            pre_test()
            sh '''
            cd ${WKC}/tests
            ./test-all.sh b1
            date'''
          }
        }
L
liuyq-617 已提交
97

L
liuyq-617 已提交
98
        stage('test_crash_gen') {
L
liuyq-617 已提交
99
          agent{label "b2"}
L
liuyq-617 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
          steps {
            pre_test()
            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                sh '''
                cd ${WKC}/tests/pytest
                ./crash_gen.sh -a -p -t 4 -s 2000
                '''
            }
            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                sh '''
                cd ${WKC}/tests/pytest
                ./handle_crash_gen_val_log.sh
                '''
            }
            sh '''
L
liuyq-617 已提交
115
            date
L
liuyq-617 已提交
116 117 118 119 120 121
            cd ${WKC}/tests
            ./test-all.sh b2
            date
            '''
          }
        }
L
liuyq-617 已提交
122

L
liuyq-617 已提交
123
        stage('test_valgrind') {
L
liuyq-617 已提交
124
          agent{label "b3"}
L
liuyq-617 已提交
125

L
liuyq-617 已提交
126 127
          steps {
            pre_test()
L
liuyq-617 已提交
128 129 130 131 132 133 134
            catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                sh '''
                cd ${WKC}/tests/pytest
                ./valgrind-test.sh 2>&1 > mem-error-out.log
                ./handle_val_log.sh
                '''
            }           
L
liuyq-617 已提交
135 136 137 138 139 140 141
            sh '''
            date
            cd ${WKC}/tests
            ./test-all.sh b3
            date'''
          }
        }
L
liuyq-617 已提交
142
        
L
liuyq-617 已提交
143 144
    }
  }
L
liuyq-617 已提交
145 146 147
  }
   
}