-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REMOVEME: Test junit output with custom Jenkinsfile
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
}} | ||
) | ||
}}}} |