Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
String cron_string = BRANCH_NAME == "master" ? "0 1 * * *" : ""
EXTRA_ARGS = startedByTimer() ? " -DBUILD_LongRunningTests=ON " : ""
pipeline {
agent none
triggers {
cron(cron_string)
}
stages {
stage('Continuous') {
parallel {
stage('Windows') {
agent {
label 'windows'
}
stages
{
stage('Build')
{
steps {
buildCmake('-DBUILD_TESTING=ON -DQT_QMAKE_EXECUTABLE="C:\\mes\\toolkits\\Qt\\5.9.6\\msvc2017_64\\bin\\qmake.exe"' + EXTRA_ARGS,'', 'Visual Studio 15 2017 Win64')
}
}
stage('Test')
{
steps {
bat '''if exist "./TestReport" rd /S /Q "./TestReport" 2>nul'''
dir('build/MES-build') {
bat(script: 'runTests.bat')
}
}
post {
always {
xunit(thresholds: [skipped(failureThreshold: '0'), failed(failureThreshold: '0')], tools: [CTest(pattern: 'TestReport/*.xml')],
testTimeMargin: '0',thresholdMode: 0)
}
}
}
}
}
stage('Linux') {
agent {
label 'linux'
}
stages
{
stage('Build')
{
steps {
buildCmake('-DBUILD_TESTING=ON -DWITH_COVERAGE=ON ' + EXTRA_ARGS, '-j 8')
}
}
stage('Test')
{
steps {
sh 'rm -rf ./TestReport/*'
wrap([$class: 'Xvfb',displayName: 10]) {
dir('build/MES-build') {
sh './runTests.sh'
}
}
}
post {
always {
xunit(thresholds: [skipped(failureThreshold: '0'), failed(failureThreshold: '0')], tools: [CTest(pattern: 'TestReport/*.xml')],
testTimeMargin: '0',thresholdMode: 0)
}
}
}
stage('Coverage')
{
steps {
createCoverage()
}
post {
always {
publishHTML(allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'report', reportFiles: 'index.html', reportName: 'GCov Report', reportTitles: 'Coverage')
}
}
}
}
}
stage('MemCheck') {
agent {
label 'memcheck'
}
when {
// Only do a memcheck when this is a nightly build
expression {
startedByTimer() == true
}
}
stages
{
stage('Build')
{
steps {
buildCmake('-DWITH_MEMCHECK=ON', '-j 8')
}
}
stage('Memcheck')
{
steps {
wrap([$class: 'Xvfb',displayName: 10]) {
ctest(installation: 'InSearchPath', arguments: '-j 4 --output-on-failure --no-compress-output -D ExperimentalMemCheck -T Submit', workingDir: 'build/MES-build')
}
}
post {
success {
publishValgrind(pattern: "*.log",failBuildOnMissingReports: false,publishResultsForFailedBuilds: true,
failBuildOnInvalidReports: true,publishResultsForAbortedBuilds: true, sourceSubstitutionPaths: "",
failThresholdInvalidReadWrite: "0",failThresholdDefinitelyLost: "0",failThresholdTotal: "0", unstableThresholdInvalidReadWrite: "0",
unstableThresholdDefinitelyLost: "0", unstableThresholdTotal: "0")
}
}
}
}
}
stage('Android') {
agent {
label 'android'
}
environment {
ANDROID_NDK = "$HOME/Android/Sdk/ndk-bundle"
PATH = "$HOME/Android/Sdk/platform-tools:$HOME/Android/Sdk/build-tools/27.0.3:$HOME/Android/Sdk/tools/bin:$PATH"
}
stages
{
stage('Build')
{
steps {
sh 'printenv'
sh "mkdir -p build/ && cd build && cmake ${workspace} -DMES_CI_BUILD=ON -DCMAKE_TOOLCHAIN_FILE=CMake/toolchains/android/toolchain-android-device.cmake -G Ninja && cmake --build . -- -j4"
}
}
}
}
stage('iOS') {
agent {
label 'mac'
}
when {
// Only do an iOS build when this is a nightly build
expression {
startedByTimer() == true
}
}
stages
{
stage('Build')
{
steps {
sh 'printenv'
buildXCode()
}
}
}
}
}
}
}
}
def createCoverage()
{
sh '''lcov -c -d . -d build/MES-build -o coverage.info --no-external &&
lcov -e coverage.info "`pwd`/Code/*" -o coverage.code.info &&
lcov -e coverage.info "`pwd`/Applications/*" -o coverage.app.info &&
lcov -a coverage.app.info -a coverage.code.info -o coverage.merged.info &&
mkdir -p report && cd report && genhtml ../coverage.merged.info'''
}
def buildCmake(String args = '', String buildArgs = '', String gen='',String dir='build')
{
String combined = "-DMES_CI_BUILD=ON " + args
cmakeBuild(installation: 'InSearchPath', buildDir: dir, cmakeArgs: combined, buildType: 'Debug',
generator:gen , steps: [[args: '-- ' + buildArgs, withCmake: true]])
}
def startedByTimer()
{
return currentBuild.rawBuild.getCauses().any { it2 -> it2 instanceof hudson.triggers.TimerTrigger.TimerTriggerCause }
}
def buildXCode()
{
dir('../../bin/MES-Release-iphoneos') {
sh 'rm -rf ./*'
}
cmakeBuild(installation: 'InSearchPath', buildDir: '../../bin/MES-Release-iphoneos', steps: [[args: '-- -j 4', withCmake: true]],
cmakeArgs: "-DCMAKE_TOOLCHAIN_FILE=${workspace}/CMake/toolchains/IOS/toolchain-ios-device.cmake -DMES_CI_BUILD=ON", buildType: 'Debug',workingDir: "${workspace}")
dir('Applications/pocket/client/ios') {
sh('xcodebuild -project POCKET.xcodeproj CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -alltargets -configuration Release')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.