Jenkinsfile 1.64 KB
Newer Older
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 30 31
def getRepoURL() {
  sh "git config --get remote.origin.url > .git/remote-url"
  return readFile(".git/remote-url").trim()
}
 
def getCommitSha() {
  sh "git rev-parse HEAD > .git/current-commit"
  return readFile(".git/current-commit").trim()
}
 
def updateGithubCommitStatus(build) {
  // workaround https://issues.jenkins-ci.org/browse/JENKINS-38674
  repoUrl = getRepoURL()
  commitSha = getCommitSha()
 
  step([
    $class: 'GitHubCommitStatusSetter',
    reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
    commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitSha],
    errorHandlers: [[$class: 'ShallowAnyErrorHandler']],
    statusResultSource: [
      $class: 'ConditionalStatusResultSource',
      results: [
        [$class: 'BetterThanOrEqualBuildResult', result: 'SUCCESS', state: 'SUCCESS', message: build.description],
        [$class: 'BetterThanOrEqualBuildResult', result: 'FAILURE', state: 'FAILURE', message: build.description],
        [$class: 'AnyBuildResult', state: 'FAILURE', message: 'Loophole']
      ]
    ]
  ])
}

32

Floris Berendsen's avatar
Floris Berendsen committed
33
node('lkeb-vm-test') {
34 35 36 37 38
  stage('Init') {
    cmake = tool 'CMake 3.5.1'
    sh 'rm -rf build'
    sh 'mkdir -p build'
  }
Floris Berendsen's avatar
Floris Berendsen committed
39

40 41 42 43 44 45 46 47
  timeout(120) {
    stage('Checkout') {
      sh 'mkdir -p src'
      dir('src') {
        checkout scm
      }
    }
    stage('SuperBuild') {
48 49
      dir('build') {
        sh "`dirname ${ cmake }`/ctest --script ../src/SuperBuild/CTest.cmake"
50 51 52 53 54 55 56 57 58 59 60
      }
    }
    stage('Test') {
      dir('build/SuperElastix-build') {
        sh "`dirname ${ cmake }`/ctest --script ../../src/CTest.cmake"
      }
    }
    dir('src') {
      updateGithubCommitStatus(currentBuild)
    }
  }
61
}