-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jenkinsfile1
99 lines (86 loc) · 3.77 KB
/
Jenkinsfile1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
def getRepoURL() {
sh "mkdir -p .git"
sh "git config --get remote.origin.url > .git/remote-url"
return readFile(".git/remote-url").trim()
}
def getCommitSha() {
sh "mkdir -p .git"
sh "git rev-parse HEAD > .git/current-commit"
return readFile(".git/current-commit").trim()
}
def updateGithubCommitStatus(build, String context, String buildUrl, String message, String state) {
// workaround https://issues.jenkins-ci.org/browse/JENKINS-38674
repoUrl = getRepoURL()
commitSha = getCommitSha()
println "Updating Github Commit Status"
println "repoUrl $repoUrl"
println "commitSha $commitSha"
println "build result: ${build.result}, currentResult: ${build.currentResult}"
step([
$class: 'GitHubCommitStatusSetter',
reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitSha],
errorHandlers: [[$class: 'ShallowAnyErrorHandler']],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: context],
statusBackrefSource: [$class: "ManuallyEnteredBackrefSource", backref: buildUrl],
statusResultSource: [
$class: 'ConditionalStatusResultSource',
results: [
[$class: 'AnyBuildResult', state: state, message: message]
]
]
])
}
def functionalTestBatchReportDirectory="target/functionalTestBatchReportDirectory"
pipeline {
agent any
options {
disableConcurrentBuilds()
}
stages {
stage('Test Execute') {
steps {
updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "In Progress", "PENDING")
dir(path: 'ModelCatalogueCorePluginTestApp') {
// updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "Installing Node Modules", "PENDING")
// sh 'npm install'
// updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "Installing Bower Components", "PENDING")
// sh 'bower install'
updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "Running Functional Tests", "PENDING")
sh 'echo $PWD'
sh "mkdir -p ${functionalTestBatchReportDirectory}"
wrap([$class: 'Xvfb']) {
sh "./scripts/testing/runFunctionalTestBatches.sh -testReportDir=${functionalTestBatchReportDirectory} -grailsCommand=/opt/grails/bin/grails -Dserver.port=8081 -Dgeb.env=chrome -DdownloadFilepath=/home/ubuntu/download -Dwebdriver.chrome.driver=/opt/chromedriver"
}
script {
ALLFAILED = sh (script: "cat ${functionalTestBatchReportDirectory}/allFailed.html", returnStdout: true)
echo "ALLFAILED: ${ALLFAILED}"
if (ALLFAILED.contains("Failed Tests")) {
error("Some tests failed")
}
}
}
}
post {
always {
publishHTML(target: [allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "ModelCatalogueCorePluginTestApp/${functionalTestBatchReportDirectory}",
reportFiles: 'allFailed.html',
reportName: 'HTML Report',
reportTitles: ''])
}
failure {
updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "Build Failed.", 'FAILURE')
}
success {
updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "Build Success!", 'SUCCESS')
}
unstable {
updateGithubCommitStatus(currentBuild, "continuous-integration/jenkinsSolo1", BUILD_URL, "Build Unstable.", 'UNSTABLE')
}
}
}
}
}