mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
Merge pull request #5668 from corda/add_publishing_tests_to_regression_builds
add smoke tests via comment trigger build
This commit is contained in:
commit
ed50016ed0
85
.ci/dev/smoke/Jenkinsfile
vendored
85
.ci/dev/smoke/Jenkinsfile
vendored
@ -4,64 +4,75 @@ import static com.r3.build.BuildControl.killAllExistingBuildsForJob
|
||||
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
|
||||
|
||||
pipeline {
|
||||
agent { label 'k8s' }
|
||||
options { timestamps() }
|
||||
|
||||
triggers {
|
||||
issueCommentTrigger('.*smoke tests.*')
|
||||
}
|
||||
|
||||
agent { label 'k8s' }
|
||||
options { timestamps() }
|
||||
|
||||
environment {
|
||||
DOCKER_TAG_TO_USE = "${env.GIT_COMMIT.subSequence(0, 8)}st"
|
||||
EXECUTOR_NUMBER = "${env.EXECUTOR_NUMBER}"
|
||||
BUILD_ID = "${env.BUILD_ID}-${env.JOB_NAME}"
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Smoke Tests') {
|
||||
stage('Corda Smoke Tests') {
|
||||
steps {
|
||||
script {
|
||||
pullRequest.createStatus(status: 'pending',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Building',
|
||||
targetUrl: "${env.JOB_URL}")
|
||||
}
|
||||
if (currentBuildTriggeredByComment()) {
|
||||
stage('Run Smoke Tests') {
|
||||
script {
|
||||
pullRequest.createStatus(status: 'pending',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Running',
|
||||
targetUrl: "${env.JOB_URL}")
|
||||
}
|
||||
|
||||
withCredentials([string(credentialsId: 'container_reg_passwd', variable: 'DOCKER_PUSH_PWD')]) {
|
||||
sh "./gradlew " +
|
||||
"-DbuildId=\"\${BUILD_ID}\" " +
|
||||
"-Dkubenetize=true " +
|
||||
"-DpreAllocatePods=true " +
|
||||
"-Ddocker.push.password=\"\${DOCKER_PUSH_PWD}\" " +
|
||||
"-Ddocker.work.dir=\"/tmp/\${EXECUTOR_NUMBER}\" " +
|
||||
"-Ddocker.build.tag=\"\${DOCKER_TAG_TO_USE}\"" +
|
||||
" allParallelSmokeTest"
|
||||
withCredentials([string(credentialsId: 'container_reg_passwd', variable: 'DOCKER_PUSH_PWD')]) {
|
||||
sh "./gradlew " +
|
||||
"-Dkubenetize=true " +
|
||||
"-Ddocker.push.password=\"\${DOCKER_PUSH_PWD}\" " +
|
||||
"-Ddocker.work.dir=\"/tmp/\${EXECUTOR_NUMBER}\" " +
|
||||
" clean allParallelSmokeTest --stacktrace"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
|
||||
always {
|
||||
junit testResults: '**/build/test-results-xml/**/*.xml', allowEmptyResults: false
|
||||
script {
|
||||
if (currentBuildTriggeredByComment()) {
|
||||
archiveArtifacts artifacts: '**/pod-logs/**/*.log', fingerprint: false
|
||||
junit '**/build/test-results-xml/**/*.xml'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
success {
|
||||
script {
|
||||
pullRequest.createStatus(status: 'success',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Passed',
|
||||
targetUrl: "${env.JOB_URL}testResults")
|
||||
if (currentBuildTriggeredByComment()) {
|
||||
pullRequest.createStatus(status: 'success',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Passed',
|
||||
targetUrl: "${env.JOB_URL}testResults")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
failure {
|
||||
script {
|
||||
pullRequest.createStatus(status: 'failure',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Failed',
|
||||
targetUrl: "${env.JOB_URL}testResults")
|
||||
if (currentBuildTriggeredByComment()) {
|
||||
pullRequest.createStatus(status: 'failure',
|
||||
context: 'continuous-integration/jenkins/pr-merge/smokeTest',
|
||||
description: 'Smoke Tests Failed',
|
||||
targetUrl: "${env.JOB_URL}testResults")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,4 +80,18 @@ pipeline {
|
||||
deleteDir() /* clean up our workspace */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
def currentBuildTriggeredByComment() {
|
||||
def triggerCause = currentBuild.rawBuild.getCause(org.jenkinsci.plugins.pipeline.github.trigger.IssueCommentCause)
|
||||
if (triggerCause) {
|
||||
echo("Build was started by ${triggerCause.userLogin}, who wrote: " +
|
||||
"\"${triggerCause.comment}\", which matches the " +
|
||||
"\"${triggerCause.triggerPattern}\" trigger pattern.")
|
||||
} else {
|
||||
echo('Build was not started by a trigger')
|
||||
}
|
||||
|
||||
return triggerCause != null
|
||||
}
|
@ -257,7 +257,7 @@ public class KubesTest extends DefaultTask {
|
||||
client.pods().delete(createdPod);
|
||||
client.persistentVolumeClaims().delete(pvc);
|
||||
}
|
||||
return new KubePodResult(resCode, podOutput, binaryResults);
|
||||
return new KubePodResult(podIdx, resCode, podOutput, binaryResults);
|
||||
});
|
||||
} catch (Retry.RetryException e) {
|
||||
throw new RuntimeException("Failed to build in pod " + podName + " (" + podIdx + "/" + numberOfPods + ") in " + numberOfRetries + " attempts", e);
|
||||
|
@ -5,11 +5,13 @@ import java.util.Collection;
|
||||
|
||||
public class KubePodResult {
|
||||
|
||||
private final int podIndex;
|
||||
private final int resultCode;
|
||||
private final File output;
|
||||
private final Collection<File> binaryResults;
|
||||
|
||||
public KubePodResult(int resultCode, File output, Collection<File> binaryResults) {
|
||||
public KubePodResult(int podIndex, int resultCode, File output, Collection<File> binaryResults) {
|
||||
this.podIndex = podIndex;
|
||||
this.resultCode = resultCode;
|
||||
this.output = output;
|
||||
this.binaryResults = binaryResults;
|
||||
@ -26,4 +28,8 @@ public class KubePodResult {
|
||||
public Collection<File> getBinaryResults() {
|
||||
return binaryResults;
|
||||
}
|
||||
|
||||
public int getPodIndex() {
|
||||
return podIndex;
|
||||
}
|
||||
}
|
||||
|
@ -151,12 +151,12 @@ public class KubesReporting extends DefaultTask {
|
||||
|
||||
if (!containersWithNonZeroReturnCodes.isEmpty()) {
|
||||
String reportUrl = new ConsoleRenderer().asClickableFileUrl(new File(destinationDir, "index.html"));
|
||||
if (shouldPrintOutput){
|
||||
if (shouldPrintOutput) {
|
||||
containersWithNonZeroReturnCodes.forEach(podResult -> {
|
||||
try {
|
||||
System.out.println("\n##### CONTAINER OUTPUT START #####");
|
||||
System.out.println("\n##### CONTAINER " + podResult.getPodIndex() + " OUTPUT START #####");
|
||||
IOUtils.copy(new FileInputStream(podResult.getOutput()), System.out);
|
||||
System.out.println("##### CONTAINER OUTPUT END #####\n");
|
||||
System.out.println("##### CONTAINER " + podResult.getPodIndex() + " OUTPUT END #####\n");
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user