Jenkinsfile 1.59 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 34
node('lkeb-vm-test') {
	stage('Init') {
Peter van 't Hof's avatar
Peter van 't Hof committed
35
		cmake = tool 'CMake 3.5.1'
36
		sh 'rm -rf build'
Floris Berendsen's avatar
Floris Berendsen committed
37
		sh 'mkdir -p build'
Floris Berendsen's avatar
Floris Berendsen committed
38 39
	}

Floris Berendsen's avatar
Floris Berendsen committed
40
	timeout(120) {
Floris Berendsen's avatar
Floris Berendsen committed
41
		stage('Checkout') {
Floris Berendsen's avatar
Floris Berendsen committed
42
			sh 'mkdir -p src'
Floris Berendsen's avatar
Floris Berendsen committed
43
			dir('src') {
Floris Berendsen's avatar
Floris Berendsen committed
44
				checkout scm
Floris Berendsen's avatar
Floris Berendsen committed
45 46 47 48
			}
		}
		stage('Build') {
			dir('build') {
Peter van 't Hof's avatar
Peter van 't Hof committed
49
				sh "${ cmake } ../src/SuperBuild"
50
				sh 'make clean'
Floris Berendsen's avatar
Floris Berendsen committed
51
				sh 'make -j4'
Floris Berendsen's avatar
Floris Berendsen committed
52
			}
Floris Berendsen's avatar
Floris Berendsen committed
53
		}
54 55 56
		dir('src') {
			updateGithubCommitStatus(currentBuild)
		}
Floris Berendsen's avatar
Floris Berendsen committed
57 58 59 60
	}

	timeout(45) {
		stage('Test') {
61
			dir('build/SuperElastix-build') {
Peter van 't Hof's avatar
Peter van 't Hof committed
62
				sh "`dirname ${ cmake }`/ctest"
63
				sh 'make Continuous'
Floris Berendsen's avatar
Floris Berendsen committed
64
			}
Floris Berendsen's avatar
Floris Berendsen committed
65 66
		}
	}
67
}