Skip to content

Commit

Permalink
REMOVEME: Test junit output with custom Jenkinsfile
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Mar 14, 2018
1 parent 1c6bb55 commit 087e114
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!groovy

def VERSION = "latest"
def IMAGE = "quay.io/ipfs/go-ipfs:$VERSION"
def image = docker.image(IMAGE)

@NonCPS
def runArgs() {
def pass = ["JENKINS_URL", "ghprbSourceBranch", "GIT_BRANCH", "ghprbActualCommit",
"TERM", "GIT_COMMIT", "BUILD_NUMBER", "ghprbPullId", "BUILD_URL"]
def override = [color: "t", TEST_NO_FUSE: "1", TEST_VERBOSE: "1"]
def newEnv = [:]
pass.each {c -> newEnv[c] = env[c] ?: ""}
newEnv.putAll(override)
return newEnv.collect { k, v -> "-e \"$k=$v\"" }.join(" ")
}

ansiColor('xterm') {withEnv(["TERM=xterm-color"]){ timeout(time: 15, unit: 'MINUTES'){
stage("Build Container") {
node(label: 'linux') {
checkout scm
VERSION = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
IMAGE = "quay.io/ipfs/go-ipfs:$VERSION"
image = docker.image(IMAGE)

docker.build(IMAGE, "-f ci/Dockerfile.buildenv .")
}
}

def dexec = "docker exec"

stage("Checks") {
parallel(
'go fmt': { node(label: 'linux') {
image.withRun runArgs(), { c ->
sh "$dexec ${c.id} make test_go_fmt"
}
}},
'go build': { node(label: 'linux') {
// due to bug in Jenkins (JENKINS-38268) names of closure params have to be different
image.withRun runArgs(), { c1 ->
sh "$dexec ${c1.id} make cmd/ipfs/ipfs"
sh "$dexec ${c1.id} sh -xc 'cp cmd/ipfs/ipfs cmd/ipfs/dist; cd cmd/ipfs/dist; tar -czvf ../go-ipfs_linux-amd64.tar.gz .'"
sh "docker cp ${c1.id}:/go/src/github.com/ipfs/go-ipfs/cmd/ipfs/go-ipfs_linux-amd64.tar.gz go-ipfs_linux-amd64-${env.BUILD_NUMBER}.tar.gz"
archiveArtifacts artifacts: "go-ipfs_linux-amd64-${env.BUILD_NUMBER}.tar.gz", fingerprint: true
}
}}
)
}

stage("Tests & Coverage") {
parallel(
'go test': { node(label: 'linux') {
image.withRun runArgs(), { c ->
sh "$dexec ${c.id} make -j3 -Otarget test_go_expensive"
}
}},
'sharness': { node(label: 'linux') {
image.withRun runArgs(), { c1 ->
try {
sh "$dexec ${c1.id} make -j3 -Otarget test/sharness/test-results/sharness.xml CONTINUE_ON_S_FAILURE=1"
sh "docker cp ${c1.id}:/go/src/github.com/ipfs/go-ipfs/test/sharness/test-results/sharness.xml sharness-${env.BUILD_NUMBER}.xml || true"
} catch (err) {
throw err
} finally {
junit allowEmptyResults: true, testResults: 'sharness-*.xml'
}
}
}}
)
}}}}

0 comments on commit 087e114

Please sign in to comment.