2019-04-26 20:25:58 +02:00
|
|
|
def projectName = "dft_tools" /* set to app/repo name */
|
|
|
|
|
|
|
|
/* which platform to build documentation on */
|
2018-03-23 20:35:56 +01:00
|
|
|
def documentationPlatform = "ubuntu-clang"
|
2019-04-26 20:25:58 +02:00
|
|
|
/* depend on triqs upstream branch/project */
|
2018-02-22 20:16:45 +01:00
|
|
|
def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME
|
|
|
|
def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F')
|
2019-04-26 20:25:58 +02:00
|
|
|
/* whether to publish the results (disabled for template project) */
|
2018-03-23 20:35:56 +01:00
|
|
|
def publish = !env.BRANCH_NAME.startsWith("PR-")
|
2018-02-14 22:35:07 +01:00
|
|
|
|
2018-02-12 20:11:41 +01:00
|
|
|
properties([
|
|
|
|
disableConcurrentBuilds(),
|
2018-02-14 22:35:07 +01:00
|
|
|
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')),
|
2018-02-12 20:11:41 +01:00
|
|
|
pipelineTriggers([
|
|
|
|
upstream(
|
|
|
|
threshold: 'SUCCESS',
|
2018-02-14 22:35:07 +01:00
|
|
|
upstreamProjects: triqsProject
|
2018-02-12 20:11:41 +01:00
|
|
|
)
|
|
|
|
])
|
|
|
|
])
|
|
|
|
|
2018-03-23 20:35:56 +01:00
|
|
|
/* map of all builds to run, populated below */
|
2018-02-12 20:11:41 +01:00
|
|
|
def platforms = [:]
|
|
|
|
|
2019-04-26 20:25:58 +02:00
|
|
|
/****************** linux builds (in docker) */
|
|
|
|
/* Each platform must have a cooresponding Dockerfile.PLATFORM in triqs/packaging */
|
2018-02-12 20:11:41 +01:00
|
|
|
def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "centos-gcc"]
|
2018-03-23 20:35:56 +01:00
|
|
|
/* .each is currently broken in jenkins */
|
2018-02-12 20:11:41 +01:00
|
|
|
for (int i = 0; i < dockerPlatforms.size(); i++) {
|
|
|
|
def platform = dockerPlatforms[i]
|
2018-03-07 21:27:16 +01:00
|
|
|
platforms[platform] = { -> node('docker') {
|
|
|
|
stage(platform) { timeout(time: 1, unit: 'HOURS') {
|
|
|
|
checkout scm
|
|
|
|
/* construct a Dockerfile for this base */
|
|
|
|
sh """
|
2019-04-26 20:25:58 +02:00
|
|
|
( echo "FROM flatironinstitute/triqs:${triqsBranch}-${env.STAGE_NAME}" ; sed '0,/^FROM /d' Dockerfile ) > Dockerfile.jenkins
|
2018-03-07 21:27:16 +01:00
|
|
|
mv -f Dockerfile.jenkins Dockerfile
|
|
|
|
"""
|
|
|
|
/* build and tag */
|
2019-04-26 20:25:58 +02:00
|
|
|
def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg APPNAME=${projectName} --build-arg BUILD_DOC=${platform==documentationPlatform} .")
|
2018-03-23 20:35:56 +01:00
|
|
|
if (!publish || platform != documentationPlatform) {
|
2018-03-07 21:27:16 +01:00
|
|
|
/* but we don't need the tag so clean it up (except for documentation) */
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "docker rmi --no-prune ${img.imageName()}"
|
2018-02-12 20:11:41 +01:00
|
|
|
}
|
2018-03-07 21:27:16 +01:00
|
|
|
} }
|
2018-02-22 20:16:45 +01:00
|
|
|
} }
|
2018-02-12 20:11:41 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 20:25:58 +02:00
|
|
|
/****************** osx builds (on host) */
|
2018-02-14 22:35:07 +01:00
|
|
|
def osxPlatforms = [
|
|
|
|
["gcc", ['CC=gcc-7', 'CXX=g++-7']],
|
2018-06-08 18:10:58 +02:00
|
|
|
["clang", ['CC=$BREW/opt/llvm/bin/clang', 'CXX=$BREW/opt/llvm/bin/clang++', 'CXXFLAGS=-I$BREW/opt/llvm/include', 'LDFLAGS=-L$BREW/opt/llvm/lib']]
|
2018-02-14 22:35:07 +01:00
|
|
|
]
|
|
|
|
for (int i = 0; i < osxPlatforms.size(); i++) {
|
|
|
|
def platformEnv = osxPlatforms[i]
|
|
|
|
def platform = platformEnv[0]
|
2018-03-07 21:27:16 +01:00
|
|
|
platforms["osx-$platform"] = { -> node('osx && triqs') {
|
|
|
|
stage("osx-$platform") { timeout(time: 1, unit: 'HOURS') {
|
|
|
|
def srcDir = pwd()
|
|
|
|
def tmpDir = pwd(tmp:true)
|
|
|
|
def buildDir = "$tmpDir/build"
|
|
|
|
def installDir = "$tmpDir/install"
|
2018-03-23 20:35:56 +01:00
|
|
|
def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}"
|
2018-03-07 21:27:16 +01:00
|
|
|
dir(installDir) {
|
|
|
|
deleteDir()
|
|
|
|
}
|
2018-02-14 22:35:07 +01:00
|
|
|
|
2018-03-07 21:27:16 +01:00
|
|
|
checkout scm
|
2018-06-08 18:10:58 +02:00
|
|
|
dir(buildDir) { withEnv(platformEnv[1].collect { it.replace('\$BREW', env.BREW) } + [
|
|
|
|
"PATH=$triqsDir/bin:${env.BREW}/bin:/usr/bin:/bin:/usr/sbin",
|
2019-04-26 20:25:58 +02:00
|
|
|
"CPLUS_INCLUDE_PATH=$triqsDir/include:${env.BREW}/include",
|
2018-06-08 18:10:58 +02:00
|
|
|
"LIBRARY_PATH=$triqsDir/lib:${env.BREW}/lib",
|
2019-04-26 20:25:58 +02:00
|
|
|
"CMAKE_PREFIX_PATH=$triqsDir/lib/cmake/triqs"]) {
|
2018-03-07 21:27:16 +01:00
|
|
|
deleteDir()
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir"
|
|
|
|
sh "make -j3"
|
2018-03-07 21:27:16 +01:00
|
|
|
try {
|
2018-11-29 22:01:39 +01:00
|
|
|
sh "make test CTEST_OUTPUT_ON_FAILURE=1"
|
2018-03-07 21:27:16 +01:00
|
|
|
} catch (exc) {
|
|
|
|
archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log')
|
|
|
|
throw exc
|
|
|
|
}
|
|
|
|
sh "make install"
|
|
|
|
} }
|
|
|
|
} }
|
2018-02-22 20:16:45 +01:00
|
|
|
} }
|
2018-02-14 22:35:07 +01:00
|
|
|
}
|
|
|
|
|
2019-04-26 20:25:58 +02:00
|
|
|
/****************** wrap-up */
|
2018-02-22 23:48:32 +01:00
|
|
|
try {
|
|
|
|
parallel platforms
|
2018-03-23 20:35:56 +01:00
|
|
|
if (publish) { node("docker") {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* Publish results */
|
2018-03-23 20:35:56 +01:00
|
|
|
stage("publish") { timeout(time: 1, unit: 'HOURS') {
|
|
|
|
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
2019-04-26 20:25:58 +02:00
|
|
|
def release = env.BRANCH_NAME == "master" || env.BRANCH_NAME == "unstable" || sh(returnStdout: true, script: "git describe --exact-match HEAD || true").trim()
|
2018-03-23 20:35:56 +01:00
|
|
|
def workDir = pwd()
|
2019-04-26 20:25:58 +02:00
|
|
|
/* Update documention on gh-pages branch */
|
2018-03-23 20:35:56 +01:00
|
|
|
dir("$workDir/gh-pages") {
|
2018-06-22 17:07:34 +02:00
|
|
|
def subdir = "${projectName}/${env.BRANCH_NAME}"
|
|
|
|
git(url: "ssh://git@github.com/TRIQS/TRIQS.github.io.git", branch: "master", credentialsId: "ssh", changelog: false)
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "rm -rf ${subdir}"
|
|
|
|
docker.image("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${documentationPlatform}").inside() {
|
2019-04-26 20:25:58 +02:00
|
|
|
sh "cp -rp \$INSTALL/share/doc/triqs_${projectName} ${subdir}"
|
2018-03-07 21:27:16 +01:00
|
|
|
}
|
2018-03-23 20:35:56 +01:00
|
|
|
sh "git add -A ${subdir}"
|
|
|
|
sh """
|
2018-06-22 17:07:34 +02:00
|
|
|
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Generated documentation for ${subdir}' -m '${env.BUILD_TAG} ${commit}'
|
2018-03-23 20:35:56 +01:00
|
|
|
"""
|
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
2018-12-04 19:50:12 +01:00
|
|
|
sh "git push origin master || { git pull --rebase origin master && git push origin master ; }"
|
2018-03-23 20:35:56 +01:00
|
|
|
}
|
2019-04-29 17:55:14 +02:00
|
|
|
/* Update packaging repo submodule */
|
|
|
|
if (release) { dir("$workDir/packaging") { try {
|
|
|
|
git(url: "ssh://git@github.com/TRIQS/packaging.git", branch: env.BRANCH_NAME, credentialsId: "ssh", changelog: false)
|
2019-04-26 20:34:19 +02:00
|
|
|
sh "test -d triqs_${projectName}"
|
2019-04-26 20:25:58 +02:00
|
|
|
sh "echo '160000 commit ${commit}\ttriqs_${projectName}' | git update-index --index-info"
|
2018-03-23 20:35:56 +01:00
|
|
|
sh """
|
|
|
|
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' --allow-empty -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
|
|
|
|
"""
|
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
2018-12-04 19:50:12 +01:00
|
|
|
sh "git push origin ${env.BRANCH_NAME} || { git pull --rebase origin ${env.BRANCH_NAME} && git push origin ${env.BRANCH_NAME} ; }"
|
2018-03-23 20:35:56 +01:00
|
|
|
} catch (err) {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* Ignore, non-critical -- might not exist on this branch */
|
2019-04-29 17:55:14 +02:00
|
|
|
echo "Failed to update packaging repo"
|
2019-04-26 20:25:58 +02:00
|
|
|
} } }
|
2018-03-23 20:35:56 +01:00
|
|
|
} }
|
|
|
|
} }
|
2018-02-22 23:48:32 +01:00
|
|
|
} catch (err) {
|
2019-04-26 20:25:58 +02:00
|
|
|
/* send email on build failure (declarative pipeline's post section would work better) */
|
2018-03-07 21:27:16 +01:00
|
|
|
if (env.BRANCH_NAME != "jenkins") emailext(
|
2018-02-22 23:48:32 +01:00
|
|
|
subject: "\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED",
|
|
|
|
body: """\$PROJECT_NAME - Build # \$BUILD_NUMBER - FAILED
|
|
|
|
|
|
|
|
$err
|
|
|
|
|
|
|
|
Check console output at \$BUILD_URL to view full results.
|
|
|
|
|
|
|
|
Building \$BRANCH_NAME for \$CAUSE
|
|
|
|
\$JOB_DESCRIPTION
|
|
|
|
|
2018-11-29 22:01:39 +01:00
|
|
|
Changes:
|
2018-02-22 23:48:32 +01:00
|
|
|
\$CHANGES
|
|
|
|
|
|
|
|
End of build log:
|
|
|
|
\${BUILD_LOG,maxLines=60}
|
|
|
|
""",
|
2019-02-21 17:01:22 +01:00
|
|
|
to: 'mzingl@flatironinstitute.org, hstrand@flatironinstitute.org, nwentzell@flatironinstitute.org, dsimon@flatironinstitute.org',
|
2018-02-22 23:48:32 +01:00
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'DevelopersRecipientProvider'],
|
|
|
|
],
|
|
|
|
replyTo: '$DEFAULT_REPLYTO'
|
|
|
|
)
|
|
|
|
throw err
|
|
|
|
}
|