Skip to content

Commit

Permalink
Merge 05c35dc into master
Browse files Browse the repository at this point in the history
  • Loading branch information
realm-ci authored Feb 28, 2017
2 parents 2a1e350 + 05c35dc commit ae157d6
Showing 1 changed file with 67 additions and 65 deletions.
132 changes: 67 additions & 65 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,45 @@ def buildSuccess = false
def rosContainer
try {
node('android') {
// Allocate a custom workspace to avoid having % in the path (it breaks ld)
ws('/tmp/realm-java') {
stage('SCM') {
checkout([
$class: 'GitSCM',
branches: scm.branches,
gitTool: 'native git',
extensions: scm.extensions + [
[$class: 'CleanCheckout'],
[$class: 'SubmoduleOption', recursiveSubmodules: true]
],
userRemoteConfigs: scm.userRemoteConfigs
])
}

def buildEnv
def rosEnv
stage('Docker build') {
// Docker image for build
buildEnv = docker.build 'realm-java:snapshot'
// Docker image for testing Realm Object Server
def dependProperties = readProperties file: 'dependencies.list'
def rosDeVersion = dependProperties["REALM_OBJECT_SERVER_DE_VERSION"]
rosEnv = docker.build 'ros:snapshot', "--build-arg ROS_DE_VERSION=${rosDeVersion} tools/sync_test_server"
}

rosContainer = rosEnv.run('-v /tmp=/tmp/.ros')

try {
timeout(time: 1, unit: 'HOURS') {
// Allocate a custom workspace to avoid having % in the path (it breaks ld)
ws('/tmp/realm-java') {
stage('SCM') {
checkout([
$class: 'GitSCM',
branches: scm.branches,
gitTool: 'native git',
extensions: scm.extensions + [
[$class: 'CleanCheckout'],
[$class: 'SubmoduleOption', recursiveSubmodules: true]
],
userRemoteConfigs: scm.userRemoteConfigs
])
}

def buildEnv
def rosEnv
stage('Docker build') {
// Docker image for build
buildEnv = docker.build 'realm-java:snapshot'
// Docker image for testing Realm Object Server
def dependProperties = readProperties file: 'dependencies.list'
def rosDeVersion = dependProperties["REALM_OBJECT_SERVER_DE_VERSION"]
rosEnv = docker.build 'ros:snapshot', "--build-arg ROS_DE_VERSION=${rosDeVersion} tools/sync_test_server"
}

rosContainer = rosEnv.run('-v /tmp=/tmp/.ros')

try {
buildEnv.inside("-e HOME=/tmp " +
"-e _JAVA_OPTIONS=-Duser.home=/tmp " +
"--privileged " +
"-v /dev/bus/usb:/dev/bus/usb " +
"-v ${env.HOME}/gradle-cache:/tmp/.gradle " +
"-v ${env.HOME}/.android:/tmp/.android " +
"-v ${env.HOME}/ccache:/tmp/.ccache " +
"-v ${env.HOME}/lcache:/tmp/.lcache " +
"--network container:${rosContainer.id}") {
"-e _JAVA_OPTIONS=-Duser.home=/tmp " +
"--privileged " +
"-v /dev/bus/usb:/dev/bus/usb " +
"-v ${env.HOME}/gradle-cache:/tmp/.gradle " +
"-v ${env.HOME}/.android:/tmp/.android " +
"-v ${env.HOME}/ccache:/tmp/.ccache " +
"-v ${env.HOME}/lcache:/tmp/.lcache " +
"--network container:${rosContainer.id}") {
stage('JVM tests') {
try {
withCredentials([[$class: 'FileBinding', credentialsId: 'c0cc8f9e-c3f1-4e22-b22f-6568392e26ae', variable: 'S3CFG']]) {
Expand All @@ -63,12 +64,12 @@ try {
publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'realm/realm-library/build/findbugs', reportFiles: 'findbugs-output.html', reportName: 'Findbugs issues'])
publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'realm/realm-library/build/reports/pmd', reportFiles: 'pmd.html', reportName: 'PMD Issues'])
step([$class: 'CheckStylePublisher',
canComputeNew: false,
defaultEncoding: '',
healthy: '',
pattern: 'realm/realm-library/build/reports/checkstyle/checkstyle.xml',
unHealthy: ''
])
canComputeNew: false,
defaultEncoding: '',
healthy: '',
pattern: 'realm/realm-library/build/reports/checkstyle/checkstyle.xml',
unHealthy: ''
])
}
}

Expand Down Expand Up @@ -102,14 +103,15 @@ try {
}
}
}
} finally {
} finally {
sh "docker logs ${rosContainer.id}"
rosContainer.stop()
}
}
}
currentBuild.rawBuild.setResult(Result.SUCCESS)
buildSuccess = true
}
currentBuild.rawBuild.setResult(Result.SUCCESS)
buildSuccess = true
} catch(Exception e) {
currentBuild.rawBuild.setResult(Result.FAILURE)
buildSuccess = false
Expand All @@ -119,14 +121,14 @@ try {
node {
withCredentials([[$class: 'StringBinding', credentialsId: 'slack-java-url', variable: 'SLACK_URL']]) {
def payload = JsonOutput.toJson([
username: 'Mr. Jenkins',
icon_emoji: ':jenkins:',
attachments: [[
'title': "The ${env.BRANCH_NAME} branch is broken!",
'text': "<${env.BUILD_URL}|Click here> to check the build.",
'color': "danger"
]]
])
username: 'Mr. Jenkins',
icon_emoji: ':jenkins:',
attachments: [[
'title': "The ${env.BRANCH_NAME} branch is broken!",
'text': "<${env.BUILD_URL}|Click here> to check the build.",
'color': "danger"
]]
])
sh "curl -X POST --data-urlencode \'payload=${payload}\' ${env.SLACK_URL}"
}
}
Expand All @@ -151,10 +153,10 @@ def stopLogCatCollector(String backgroundPid, boolean archiveLog) {
sh "kill ${backgroundPid}"
if (archiveLog) {
zip([
'zipFile': 'logcat.zip',
'archive': true,
'glob' : 'logcat.txt'
])
'zipFile': 'logcat.zip',
'archive': true,
'glob' : 'logcat.txt'
])
}
sh 'rm logcat.txt'
}
Expand All @@ -173,9 +175,9 @@ def getTagsString(Map<String, String> tags) {

def storeJunitResults(String path) {
step([
$class: 'JUnitResultArchiver',
testResults: path
])
$class: 'JUnitResultArchiver',
testResults: path
])
}

def collectAarMetrics() {
Expand All @@ -198,10 +200,10 @@ def collectAarMetrics() {

def soFiles = findFiles(glob: "realm/realm-library/build/outputs/aar/unzipped${flavor}/jni/*/librealm-jni.so")
for (def j = 0; j < soFiles.size(); j++) {
def soFile = soFiles[j]
def abiName = soFile.path.tokenize('/')[-2]
def libSize = soFile.length as String
sendMetrics('abi_size', libSize, ['flavor':flavor, 'type':abiName])
def soFile = soFiles[j]
def abiName = soFile.path.tokenize('/')[-2]
def libSize = soFile.length as String
sendMetrics('abi_size', libSize, ['flavor':flavor, 'type':abiName])
}
}
}
Expand Down

0 comments on commit ae157d6

Please sign in to comment.