mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-24 18:52:25 +08:00
Run the integration tests from the current branch
Previously, the integration test pipeline was configured to always use the tests present on the master branch. When running the pre-merge pipeline for a PR, this would result in potentially out-dated tests being run. This change runs the tests from the current branch, allowing the code and the tests to evolve together. This also disables the default checkout of the master branch, which is unnecessary when calling checkout() from the pipeline.
This commit is contained in:
@@ -42,6 +42,7 @@ pipeline {
|
||||
timestamps()
|
||||
timeout(time: 120, unit: 'MINUTES')
|
||||
buildDiscarder(logRotator(numToKeepStr: '10'))
|
||||
skipDefaultCheckout()
|
||||
}
|
||||
environment {
|
||||
PIPELINE_NAMESPACE = readFile("/run/secrets/kubernetes.io/serviceaccount/namespace").trim()
|
||||
@@ -267,6 +268,8 @@ pipeline {
|
||||
openshift.withCluster() {
|
||||
openshift.withProject(params.MBS_INTEGRATION_TEST_BUILD_CONFIG_NAMESPACE) {
|
||||
def build = c3i.buildAndWait("bc/${params.MBS_INTEGRATION_TEST_BUILD_CONFIG_NAME}",
|
||||
'-e', "MBS_GIT_REPO=${params.MBS_GIT_REPO}",
|
||||
'-e', "MBS_GIT_REF=${env.PR_NO ? params.MBS_GIT_REF : env.MBS_GIT_COMMIT}",
|
||||
'-e', "MBS_BACKEND_IMAGE=${env.BACKEND_IMAGE_REF}",
|
||||
'-e', "MBS_FRONTEND_IMAGE=${env.FRONTEND_IMAGE_REF}",
|
||||
'-e', "TEST_IMAGES='${env.BACKEND_IMAGE_REF} ${env.FRONTEND_IMAGE_REF}'",
|
||||
|
||||
@@ -108,6 +108,10 @@ objects:
|
||||
type: JenkinsPipeline
|
||||
jenkinsPipelineStrategy:
|
||||
env:
|
||||
- name: MBS_GIT_REPO
|
||||
value: "${MBS_GIT_REPO}"
|
||||
- name: MBS_GIT_REF
|
||||
value: "${MBS_GIT_REF}"
|
||||
- name: MBS_BACKEND_IMAGE
|
||||
value: "${MBS_BACKEND_IMAGE}"
|
||||
- name: MBS_FRONTEND_IMAGE
|
||||
|
||||
@@ -41,6 +41,7 @@ pipeline {
|
||||
timestamps()
|
||||
timeout(time: 60, unit: 'MINUTES')
|
||||
buildDiscarder(logRotator(numToKeepStr: '10'))
|
||||
skipDefaultCheckout()
|
||||
}
|
||||
environment {
|
||||
// Jenkins BUILD_TAG could be too long (> 63 characters) for OpenShift to consume
|
||||
@@ -52,6 +53,21 @@ pipeline {
|
||||
script {
|
||||
// Don't set ENVIRONMENT_LABEL in the environment block! Otherwise you will get 2 different UUIDs.
|
||||
env.ENVIRONMENT_LABEL = "test-${env.TEST_ID}"
|
||||
|
||||
// check out specified branch/commit
|
||||
checkout([$class: 'GitSCM',
|
||||
branches: [[name: params.MBS_GIT_REF]],
|
||||
userRemoteConfigs: [[url: params.MBS_GIT_REPO, refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pull/*/head']],
|
||||
])
|
||||
|
||||
// get current commit ID
|
||||
// FIXME: Due to a bug discribed in https://issues.jenkins-ci.org/browse/JENKINS-45489,
|
||||
// the return value of checkout() is unreliable.
|
||||
// Not working: env.MBS_GIT_COMMIT = scmVars.GIT_COMMIT
|
||||
env.MBS_GIT_COMMIT = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
|
||||
echo "Running integration tests for ${params.MBS_GIT_REF}, commit=${env.MBS_GIT_COMMIT}"
|
||||
|
||||
currentBuild.displayName = "${params.MBS_GIT_REF}: ${env.MBS_GIT_COMMIT.take(7)}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user