INFRA-1299: switching from AKS to linear builds on two Jenkins agents

* removed `.ci/dev/unit/Jenkinsfile` and
`.ci/dev/integration/Jenkinsfile` - they don't seem to be used anywhere
* switched mandatory tests to linear build - modeled after Corda
  Enterprise
* switched nightly regression tests to linear build - modeled after
  Corda Enterprise
This commit is contained in:
Waldemar Zurowski 2021-06-01 16:21:22 +02:00
parent 19274751d9
commit 8d994283c6
5 changed files with 232 additions and 230 deletions

View File

@ -1,62 +0,0 @@
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
@Library('corda-shared-build-pipeline-steps')
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
pipeline {
agent { label 'local-k8s' }
options {
timestamps()
timeout(time: 3, unit: 'HOURS')
}
environment {
DOCKER_TAG_TO_USE = "${UUID.randomUUID().toString().toLowerCase().subSequence(0, 12)}"
EXECUTOR_NUMBER = "${env.EXECUTOR_NUMBER}"
BUILD_ID = "${env.BUILD_ID}-${env.JOB_NAME}"
}
stages {
stage('Corda - Generate Build Image') {
steps {
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}\" " +
"-Ddocker.provided.tag=\"\${DOCKER_TAG_TO_USE}\"" +
" clean pushBuildImage"
}
sh "kubectl auth can-i get pods"
}
}
stage('Corda - Run Tests') {
stage('Integration Tests') {
steps {
sh "./gradlew " +
"-DbuildId=\"\${BUILD_ID}\" " +
"-Dkubenetize=true " +
"-Ddocker.tag=\"\${DOCKER_TAG_TO_USE}\"" +
" allParallelIntegrationTest"
if (env.CHANGE_ID) {
pullRequest.createStatus(status: 'success',
context: 'continuous-integration/jenkins/pr-merge/integrationTest',
description: 'Integration Tests Passed',
targetUrl: "${env.JOB_URL}/testResults")
}
}
}
}
}
post {
always {
junit '**/build/test-results-xml/**/*.xml'
}
cleanup {
deleteDir() /* clean up our workspace */
}
}
}

View File

@ -1,66 +1,164 @@
#!groovy
/**
* Jenkins pipeline to build Corda Opensource nightly regression for feature branches.
*/
@Library('corda-shared-build-pipeline-steps') @Library('corda-shared-build-pipeline-steps')
import static com.r3.build.BuildControl.killAllExistingBuildsForJob import static com.r3.build.BuildControl.killAllExistingBuildsForJob
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
/**
* Common Gradle arguments for all Gradle executions
*/
String COMMON_GRADLE_PARAMS = [
'--no-daemon',
'--stacktrace',
'--info',
'-Pcompilation.warningsAsErrors=false',
'-Ptests.failFast=true',
].join(' ')
pipeline { pipeline {
agent { label 'k8s' } agent { label 'standard' }
/*
* List options in alphabetical order
*/
options { options {
timestamps() buildDiscarder(logRotator(daysToKeepStr: '14', artifactDaysToKeepStr: '14'))
overrideIndexTriggers(false) overrideIndexTriggers(false)
buildDiscarder(logRotator(daysToKeepStr: '7', artifactDaysToKeepStr: '7')) parallelsAlwaysFailFast()
timeout(time: 3, unit: 'HOURS') timeout(time: 6, unit: 'HOURS')
timestamps()
} }
triggers { triggers {
pollSCM ignorePostCommitHooks: true, scmpoll_spec: '@midnight' pollSCM ignorePostCommitHooks: true, scmpoll_spec: '@midnight'
} }
/*
* List environment variables in alphabetical order
*/
environment { environment {
DOCKER_TAG_TO_USE = "${env.GIT_COMMIT.subSequence(0, 8)}"
EXECUTOR_NUMBER = "${env.EXECUTOR_NUMBER}"
BUILD_ID = "${env.BUILD_ID}-${env.JOB_NAME}"
ARTIFACTORY_CREDENTIALS = credentials('artifactory-credentials') ARTIFACTORY_CREDENTIALS = credentials('artifactory-credentials')
} }
stages { stages {
stage('Generate Build Image') { stage('Compile') {
steps { steps {
withCredentials([string(credentialsId: 'container_reg_passwd', variable: 'DOCKER_PUSH_PWD')]) { sh script: [
sh "./gradlew " + './gradlew',
"-Dkubenetize=true " + COMMON_GRADLE_PARAMS,
"-Ddocker.push.password=\"\${DOCKER_PUSH_PWD}\" " + 'clean',
"-Ddocker.work.dir=\"/tmp/\${EXECUTOR_NUMBER}\" " + 'jar'
"-Ddocker.build.tag=\"\${DOCKER_TAG_TO_USE}\"" + ].join(' ')
" clean pushBuildImage --stacktrace"
}
sh "kubectl auth can-i get pods"
} }
} }
stage('Regression Test') { stage('Stash') {
steps { steps {
sh "./gradlew " + stash name: 'compiled', useDefaultExcludes: false
"-DbuildId=\"\${BUILD_ID}\" " + }
"-Dkubenetize=true " + }
"-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " +
"-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + stage('All Tests') {
"-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + parallel {
"-Dgit.branch=\"\${GIT_BRANCH}\" " + stage('Another agent') {
"-Dgit.target.branch=\"\${GIT_BRANCH}\" " + agent {
" parallelRegressionTest --stacktrace" label 'standard'
}
options {
skipDefaultCheckout true
}
post {
always {
archiveArtifacts artifacts: '**/*.log', fingerprint: false
junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true
}
cleanup {
deleteDir() /* clean up our workspace */
}
}
stages {
stage('Unstash') {
steps {
unstash 'compiled'
}
}
stage('Recompile') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'jar'
].join(' ')
}
}
stage('Unit Test') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'test'
].join(' ')
}
}
stage('Proxy Integration Test') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'proxyIntegrationTest'
].join(' ')
}
}
stage('Smoke Test') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'smokeTest'
].join(' ')
}
}
stage('Slow Integration Test') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'slowIntegrationTest'
].join(' ')
}
}
}
}
stage('Same agent') {
post {
always {
archiveArtifacts artifacts: '**/*.log', fingerprint: false
junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true
}
}
stages {
stage('Integration Test') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'integrationTest'
].join(' ')
}
}
}
}
} }
} }
} }
post { post {
always {
archiveArtifacts artifacts: '**/pod-logs/**/*.log', fingerprint: false
junit testResults: '**/build/test-results-xml/**/*.xml'
}
cleanup { cleanup {
deleteDir() /* clean up our workspace */ deleteDir() /* clean up our workspace */
} }
} }
} }

View File

@ -4,27 +4,16 @@ import static com.r3.build.BuildControl.killAllExistingBuildsForJob
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
pipeline { pipeline {
agent { label 'k8s' } agent { label 'standard' }
options { options {
timestamps() timestamps()
timeout(time: 3, unit: 'HOURS') timeout(time: 3, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '14', artifactDaysToKeepStr: '14')) buildDiscarder(logRotator(daysToKeepStr: '14', artifactDaysToKeepStr: '14'))
} }
environment {
PR_CONTEXT_STRING = "PR Code Checks"
}
stages { stages {
stage('Detekt check') { stage('Detekt check') {
steps { steps {
script {
pullRequest.createStatus(
status: 'pending',
context: "${PR_CONTEXT_STRING}",
description: "Running code checks",
targetUrl: "${env.BUILD_URL}")
}
sh "./gradlew --no-daemon clean detekt" sh "./gradlew --no-daemon clean detekt"
} }
} }
@ -50,25 +39,6 @@ pipeline {
} }
post { post {
success {
script {
pullRequest.createStatus(
status: 'success',
context: "${PR_CONTEXT_STRING}",
description: 'Code checks passed',
targetUrl: "${env.BUILD_URL}")
}
}
failure {
script {
pullRequest.createStatus(
status: 'failure',
context: "${PR_CONTEXT_STRING}",
description: 'Code checks failed',
targetUrl: "${env.BUILD_URL}")
}
}
cleanup { cleanup {
deleteDir() /* clean up our workspace */ deleteDir() /* clean up our workspace */
} }

View File

@ -1,60 +0,0 @@
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
@Library('corda-shared-build-pipeline-steps')
import static com.r3.build.BuildControl.killAllExistingBuildsForJob
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
pipeline {
agent { label 'k8s' }
options {
timestamps()
timeout(time: 3, unit: 'HOURS')
}
environment {
DOCKER_TAG_TO_USE = "${UUID.randomUUID().toString().toLowerCase().subSequence(0, 12)}"
EXECUTOR_NUMBER = "${env.EXECUTOR_NUMBER}"
BUILD_ID = "${env.BUILD_ID}-${env.JOB_NAME}"
}
stages {
stage('Corda Pull Request - Generate Build Image') {
steps {
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}\" " +
"-Ddocker.provided.tag=\"\${DOCKER_TAG_TO_USE}\"" +
" clean pushBuildImage"
}
sh "kubectl auth can-i get pods"
}
}
stage('Unit Tests') {
steps {
sh "./gradlew " +
"-DbuildId=\"\${BUILD_ID}\" " +
"-Dkubenetize=true " +
"-Ddocker.tag=\"\${DOCKER_TAG_TO_USE}\"" +
" allParallelUnitTest"
if (env.CHANGE_ID) {
pullRequest.createStatus(status: 'success',
context: 'continuous-integration/jenkins/pr-merge/unitTest',
description: 'Unit Tests Passed',
targetUrl: "${env.JOB_URL}/testResults")
}
}
}
}
post {
always {
junit '**/build/test-results-xml/**/*.xml'
}
cleanup {
deleteDir() /* clean up our workspace */
}
}
}

144
Jenkinsfile vendored
View File

@ -1,64 +1,124 @@
import static com.r3.build.BuildControl.killAllExistingBuildsForJob #!groovy
/**
* Jenkins pipeline to build Corda Opensource Pull Requests.
*/
@Library('corda-shared-build-pipeline-steps') @Library('corda-shared-build-pipeline-steps')
import static com.r3.build.BuildControl.killAllExistingBuildsForJob import static com.r3.build.BuildControl.killAllExistingBuildsForJob
killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger())
/**
* Common Gradle arguments for all Gradle executions
*/
String COMMON_GRADLE_PARAMS = [
'--no-daemon',
'--stacktrace',
'--info',
'-Pcompilation.warningsAsErrors=false',
'-Ptests.failFast=true',
].join(' ')
pipeline { pipeline {
agent { label 'k8s' } agent { label 'standard' }
/*
* List options in alphabetical order
*/
options { options {
timestamps() ansiColor('xterm')
timeout(time: 3, unit: 'HOURS') buildDiscarder(logRotator(daysToKeepStr: '14', artifactDaysToKeepStr: '14'))
parallelsAlwaysFailFast()
timeout(time: 6, unit: 'HOURS')
timestamps()
} }
/*
* List environment variables in alphabetical order
*/
environment { environment {
DOCKER_TAG_TO_USE = "${env.GIT_COMMIT.subSequence(0, 8)}"
EXECUTOR_NUMBER = "${env.EXECUTOR_NUMBER}"
BUILD_ID = "${env.BUILD_ID}-${env.JOB_NAME}"
ARTIFACTORY_CREDENTIALS = credentials('artifactory-credentials') ARTIFACTORY_CREDENTIALS = credentials('artifactory-credentials')
} }
stages { stages {
stage('Corda Pull Request - Generate Build Image') { stage('Compile') {
steps { steps {
withCredentials([string(credentialsId: 'container_reg_passwd', variable: 'DOCKER_PUSH_PWD')]) { sh script: [
sh "./gradlew " + './gradlew',
"-Dkubenetize=true " + COMMON_GRADLE_PARAMS,
"-Ddocker.push.password=\"\${DOCKER_PUSH_PWD}\" " + 'clean',
"-Ddocker.work.dir=\"/tmp/\${EXECUTOR_NUMBER}\" " + 'jar'
"-Ddocker.build.tag=\"\${DOCKER_TAG_TO_USE}\"" + ].join(' ')
" clean pushBuildImage preAllocateForAllParallelIntegrationTest preAllocateForAllParallelUnitTest --stacktrace"
}
sh "kubectl auth can-i get pods"
} }
} }
stage('Corda Pull Request - Run Tests') { stage('Stash') {
steps {
stash name: 'compiled', useDefaultExcludes: false
}
}
stage('All Tests') {
parallel { parallel {
stage('Integration Tests') { stage('Another agent') {
steps { agent {
sh "./gradlew " + label 'standard'
"-DbuildId=\"\${BUILD_ID}\" " + }
"-Dkubenetize=true " + options {
"-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " + skipDefaultCheckout true
"-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + }
"-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + post {
"-Dgit.branch=\"\${GIT_BRANCH}\" " + always {
"-Dgit.target.branch=\"\${CHANGE_TARGET}\" " + archiveArtifacts artifacts: '**/*.log', fingerprint: false
" deAllocateForAllParallelIntegrationTest allParallelIntegrationTest --stacktrace" junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true
}
cleanup {
deleteDir() /* clean up our workspace */
}
}
stages {
stage('Unstash') {
steps {
unstash 'compiled'
}
}
stage('Recompile') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'jar'
].join(' ')
}
}
stage('Unit Test') {
steps {
sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'test'
].join(' ')
}
}
} }
} }
stage('Unit Tests') { stage('Same agent') {
steps { post {
sh "./gradlew " + always {
"-DbuildId=\"\${BUILD_ID}\" " + archiveArtifacts artifacts: '**/*.log', fingerprint: false
"-Dkubenetize=true " + junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true
"-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " + }
"-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + }
"-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + stages {
"-Dgit.branch=\"\${GIT_BRANCH}\" " + stage('Integration Test') {
"-Dgit.target.branch=\"\${CHANGE_TARGET}\" " + steps {
" deAllocateForAllParallelUnitTest allParallelUnitTest --stacktrace" sh script: [
'./gradlew',
COMMON_GRADLE_PARAMS,
'integrationTest'
].join(' ')
}
}
} }
} }
} }
@ -66,10 +126,6 @@ pipeline {
} }
post { post {
always {
archiveArtifacts artifacts: '**/pod-logs/**/*.log', fingerprint: false
junit '**/build/test-results-xml/**/*.xml'
}
cleanup { cleanup {
deleteDir() /* clean up our workspace */ deleteDir() /* clean up our workspace */
} }