2018-04-06 17:27:06 +02:00
|
|
|
def projectName = "app4triqs" /* set to app/repo name */
|
|
|
|
|
|
|
|
/* which platform to build documentation on */
|
2018-03-23 20:30:28 +01:00
|
|
|
def documentationPlatform = "ubuntu-clang"
|
2018-04-06 17:27:06 +02:00
|
|
|
/* depend on triqs upstream branch/project */
|
2018-03-23 20:30:28 +01:00
|
|
|
def triqsBranch = env.CHANGE_TARGET ?: env.BRANCH_NAME
|
|
|
|
def triqsProject = '/TRIQS/triqs/' + triqsBranch.replaceAll('/', '%2F')
|
2019-07-26 20:01:22 +02:00
|
|
|
/* whether to keep and publish the results */
|
|
|
|
def keepInstall = !env.BRANCH_NAME.startsWith("PR-")
|
2018-03-22 18:11:39 +01:00
|
|
|
|
|
|
|
properties([
|
|
|
|
disableConcurrentBuilds(),
|
|
|
|
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '30')),
|
2019-08-20 22:01:55 +02:00
|
|
|
pipelineTriggers(keepInstall ? [
|
2018-03-22 18:11:39 +01:00
|
|
|
upstream(
|
|
|
|
threshold: 'SUCCESS',
|
2018-03-23 20:30:28 +01:00
|
|
|
upstreamProjects: triqsProject
|
2018-03-22 18:11:39 +01:00
|
|
|
)
|
2019-08-20 22:01:55 +02:00
|
|
|
] : [])
|
2018-03-22 18:11:39 +01:00
|
|
|
])
|
|
|
|
|
2018-03-23 20:30:28 +01:00
|
|
|
/* map of all builds to run, populated below */
|
2018-03-22 18:11:39 +01:00
|
|
|
def platforms = [:]
|
|
|
|
|
2018-04-06 17:27:06 +02:00
|
|
|
/****************** linux builds (in docker) */
|
|
|
|
/* Each platform must have a cooresponding Dockerfile.PLATFORM in triqs/packaging */
|
2018-03-22 18:11:39 +01:00
|
|
|
def dockerPlatforms = ["ubuntu-clang", "ubuntu-gcc", "centos-gcc"]
|
2018-03-23 20:30:28 +01:00
|
|
|
/* .each is currently broken in jenkins */
|
2018-03-22 18:11:39 +01:00
|
|
|
for (int i = 0; i < dockerPlatforms.size(); i++) {
|
|
|
|
def platform = dockerPlatforms[i]
|
2018-03-23 20:30:28 +01:00
|
|
|
platforms[platform] = { -> node('docker') {
|
|
|
|
stage(platform) { timeout(time: 1, unit: 'HOURS') {
|
2018-06-22 17:15:27 +02:00
|
|
|
checkout scm
|
|
|
|
/* construct a Dockerfile for this base */
|
|
|
|
sh """
|
|
|
|
( echo "FROM flatironinstitute/triqs:${triqsBranch}-${env.STAGE_NAME}" ; sed '0,/^FROM /d' Dockerfile ) > Dockerfile.jenkins
|
|
|
|
mv -f Dockerfile.jenkins Dockerfile
|
|
|
|
"""
|
|
|
|
/* build and tag */
|
2018-04-06 17:29:06 +02:00
|
|
|
def img = docker.build("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${env.STAGE_NAME}", "--build-arg APPNAME=${projectName} --build-arg BUILD_DOC=${platform==documentationPlatform} .")
|
2019-07-26 20:01:22 +02:00
|
|
|
if (!keepInstall) {
|
2018-03-23 20:30:28 +01:00
|
|
|
sh "docker rmi --no-prune ${img.imageName()}"
|
2018-06-01 17:10:49 +02:00
|
|
|
}
|
|
|
|
} }
|
2018-03-23 20:30:28 +01:00
|
|
|
} }
|
2018-03-22 18:11:39 +01:00
|
|
|
}
|
|
|
|
|
2018-04-06 17:27:06 +02:00
|
|
|
/****************** osx builds (on host) */
|
2018-03-22 18:11:39 +01:00
|
|
|
def osxPlatforms = [
|
|
|
|
["gcc", ['CC=gcc-7', 'CXX=g++-7']],
|
2018-06-08 16:40:39 +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-03-22 18:11:39 +01:00
|
|
|
]
|
|
|
|
for (int i = 0; i < osxPlatforms.size(); i++) {
|
|
|
|
def platformEnv = osxPlatforms[i]
|
|
|
|
def platform = platformEnv[0]
|
2018-03-23 20:30:28 +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"
|
2019-07-26 20:01:22 +02:00
|
|
|
def installDir = keepInstall ? "${env.HOME}/install/${projectName}/${env.BRANCH_NAME}/${platform}" : "$tmpDir/install"
|
2018-03-23 20:30:28 +01:00
|
|
|
def triqsDir = "${env.HOME}/install/triqs/${triqsBranch}/${platform}"
|
|
|
|
dir(installDir) {
|
|
|
|
deleteDir()
|
|
|
|
}
|
2018-03-22 18:11:39 +01:00
|
|
|
|
2018-03-23 20:30:28 +01:00
|
|
|
checkout scm
|
2018-06-08 16:40:39 +02:00
|
|
|
dir(buildDir) { withEnv(platformEnv[1].collect { it.replace('\$BREW', env.BREW) } + [
|
|
|
|
"PATH=$triqsDir/bin:${env.BREW}/bin:/usr/bin:/bin:/usr/sbin",
|
2018-10-11 23:17:12 +02:00
|
|
|
"CPLUS_INCLUDE_PATH=$triqsDir/include:${env.BREW}/include",
|
2018-06-08 16:40:39 +02:00
|
|
|
"LIBRARY_PATH=$triqsDir/lib:${env.BREW}/lib",
|
2018-11-28 19:02:26 +01:00
|
|
|
"CMAKE_PREFIX_PATH=$triqsDir/lib/cmake/triqs"]) {
|
2018-03-23 20:30:28 +01:00
|
|
|
deleteDir()
|
2019-07-29 20:42:20 +02:00
|
|
|
/* note: this is installing into the parent (triqs) venv (install dir), which is thus shared among apps and so not be completely safe */
|
|
|
|
sh "pip install -r $srcDir/requirements.txt"
|
2018-06-22 17:15:27 +02:00
|
|
|
sh "cmake $srcDir -DCMAKE_INSTALL_PREFIX=$installDir -DTRIQS_ROOT=$triqsDir"
|
|
|
|
sh "make -j3"
|
2018-03-23 20:30:28 +01:00
|
|
|
try {
|
2018-11-29 20:20:35 +01:00
|
|
|
sh "make test CTEST_OUTPUT_ON_FAILURE=1"
|
2018-03-23 20:30:28 +01:00
|
|
|
} catch (exc) {
|
|
|
|
archiveArtifacts(artifacts: 'Testing/Temporary/LastTest.log')
|
|
|
|
throw exc
|
2018-03-22 18:11:39 +01:00
|
|
|
}
|
2018-03-23 20:30:28 +01:00
|
|
|
sh "make install"
|
|
|
|
} }
|
|
|
|
} }
|
2018-03-22 18:11:39 +01:00
|
|
|
} }
|
|
|
|
}
|
|
|
|
|
2018-04-06 17:27:06 +02:00
|
|
|
/****************** wrap-up */
|
2018-03-22 18:11:39 +01:00
|
|
|
try {
|
|
|
|
parallel platforms
|
2019-07-26 20:01:22 +02:00
|
|
|
if (keepInstall) { node("docker") {
|
2018-04-06 17:27:06 +02:00
|
|
|
/* Publish results */
|
2019-08-27 23:37:02 +02:00
|
|
|
stage("publish") { timeout(time: 5, unit: 'MINUTES') {
|
2018-03-23 20:30:28 +01:00
|
|
|
def commit = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
|
2019-04-16 23:41:46 +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:30:28 +01:00
|
|
|
def workDir = pwd()
|
2019-08-27 23:37:02 +02:00
|
|
|
lock('triqs_publish') {
|
2018-04-06 17:27:06 +02:00
|
|
|
/* Update documention on gh-pages branch */
|
2018-03-23 20:30:28 +01:00
|
|
|
dir("$workDir/gh-pages") {
|
2018-06-22 17:15:27 +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:30:28 +01:00
|
|
|
sh "rm -rf ${subdir}"
|
|
|
|
docker.image("flatironinstitute/${projectName}:${env.BRANCH_NAME}-${documentationPlatform}").inside() {
|
|
|
|
sh "cp -rp \$INSTALL/share/doc/${projectName} ${subdir}"
|
|
|
|
}
|
|
|
|
sh "git add -A ${subdir}"
|
|
|
|
sh """
|
2018-06-22 17:15:27 +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:30:28 +01:00
|
|
|
"""
|
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
2019-08-27 23:37:02 +02:00
|
|
|
sh "git push origin master"
|
2018-03-23 20:30:28 +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-29 20:51:15 +02:00
|
|
|
// note: credentials used above don't work (need JENKINS-28335)
|
|
|
|
sh """#!/bin/bash -ex
|
|
|
|
dir="${projectName}"
|
|
|
|
[[ -d triqs_\$dir ]] && dir=triqs_\$dir || [[ -d \$dir ]]
|
|
|
|
echo "160000 commit ${commit}\t\$dir" | git update-index --index-info
|
2019-05-02 19:42:36 +02:00
|
|
|
git commit --author='Flatiron Jenkins <jenkins@flatironinstitute.org>' -m 'Autoupdate ${projectName}' -m '${env.BUILD_TAG}'
|
2019-08-27 23:37:02 +02:00
|
|
|
git push origin ${env.BRANCH_NAME}
|
2018-03-23 20:30:28 +01:00
|
|
|
"""
|
|
|
|
} catch (err) {
|
2018-06-22 17:15:27 +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-01-28 21:04:03 +01:00
|
|
|
} } }
|
2019-08-27 23:37:02 +02:00
|
|
|
}
|
2018-03-23 20:30:28 +01:00
|
|
|
} }
|
|
|
|
} }
|
2018-03-22 18:11:39 +01:00
|
|
|
} catch (err) {
|
2018-04-06 17:27:06 +02:00
|
|
|
/* send email on build failure (declarative pipeline's post section would work better) */
|
2018-03-23 20:30:28 +01:00
|
|
|
if (env.BRANCH_NAME != "jenkins") emailext(
|
2018-03-22 18:11:39 +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-09-17 19:41:37 +02:00
|
|
|
Changes:
|
2018-03-22 18:11:39 +01:00
|
|
|
\$CHANGES
|
|
|
|
|
|
|
|
End of build log:
|
|
|
|
\${BUILD_LOG,maxLines=60}
|
|
|
|
""",
|
2019-07-26 21:04:01 +02:00
|
|
|
to: 'nwentzell@flatironinstitute.org',
|
2018-03-22 18:11:39 +01:00
|
|
|
recipientProviders: [
|
|
|
|
[$class: 'DevelopersRecipientProvider'],
|
|
|
|
],
|
|
|
|
replyTo: '$DEFAULT_REPLYTO'
|
|
|
|
)
|
|
|
|
throw err
|
|
|
|
}
|