c++项目的Jenkins持续集成实践
1.pipeline脚本
pipeline {
agent any
stages {
stage('拉取代码') {
steps {
deleteDir()
sh 'echo ${branch}'
checkout([$class: 'GitSCM', branches: [[name: "${branch}"]], extensions: [], userRemoteConfigs: [[credentialsId: 'a58f269b-a9c5-44cf-b16a-736bb9c785e4', url: 'http://xxxx:xxx/xxx/c.git']]])
}
}
stage('编译构建') {
steps {
sh 'mkdir build'
dir('./build') {
sh 'cmake ..'
sh 'make'
}
dir('..') {
// some block
}
}
}
stage('Cppcheck') {
steps {
script {
sh 'cppcheck src test --xml 2> cppcheck.xml'
}
}
}
stage('Publish results') {
steps {
recordIssues(tools: [cppCheck(pattern: 'cppcheck.xml')])
}
}
}
}