| // Setup some common items that at some point we will | |
| // extract and make this be the only thing required in this file... | |
| project = "cloud-init" | |
| venv_py_version = "python2.7" | |
| stage("Initiation") | |
| // NOTE(harlowja): some of these are coming in via job parameters (so that | |
| // is why you will not find the variables defined anywhere, they are | |
| // apparently injected as globals automatically...) | |
| def run_details = [ | |
| "Project": "${project}", | |
| "Project git": "${project_url}", | |
| "Project ref": "${project_ref}", | |
| "Additions git": "${additions_url}", | |
| "Additions ref": "${additions_ref}", | |
| ] | |
| def job_details = [ | |
| "Job name": "${env.JOB_NAME}", | |
| "Job build id": "${env.BUILD_ID}", | |
| "Job build number": "${env.BUILD_NUMBER}", | |
| "Job build url": "${env.BUILD_URL}", | |
| ] | |
| run_details = pretty_format(run_details) | |
| job_details = pretty_format(job_details) | |
| def start_msg = "" | |
| start_msg += "```\n" | |
| start_msg += job_details | |
| start_msg += "```\n" | |
| start_msg += "*Parameters:*\n" | |
| start_msg += "```\n" | |
| start_msg += run_details | |
| start_msg += "```\n" | |
| node { | |
| start(start_msg, { | |
| net_info() | |
| }) | |
| } | |
| stage("Checkout (external)") | |
| project_stash = "${project}.stash" | |
| project_cloner = { | |
| clone_and_stash(project_url, project_ref, project_stash) | |
| } | |
| slack_stage( | |
| "Checking out (and stashing) repo for ${project}", | |
| project_cloner) | |
| stage("Checkout (additions)") | |
| additions_stash = "${project}-additions.stash" | |
| additions_cloner = { | |
| clone_and_stash(additions_url, additions_ref, additions_stash) | |
| } | |
| slack_stage( | |
| "Checking out (and stashing) additions repo for ${project}", | |
| additions_cloner) | |
| unit_testers = [:] | |
| for(k in ['build-slave-cent7', 'build-slave-cent6']) { | |
| // Appears that we need to capture these locally... | |
| def kind = k | |
| def short_kind = kind.substring('build-slave-'.length(), kind.length()) | |
| short_kind = short_kind[0].toUpperCase() + short_kind.substring(1, short_kind.length()) | |
| unit_testers[kind] = { | |
| node(kind) { | |
| timeout(time: 3600, unit: 'SECONDS') { | |
| wrap([$class: 'AnsiColorBuildWrapper', colorMapName: 'xterm']) { | |
| clean_ws { | |
| // Get the stash! | |
| unstash(project_stash) | |
| try { | |
| sh """ | |
| virtualenv .venv | |
| source .venv/bin/activate | |
| pip install pip setuptools --upgrade | |
| pip install -r test-requirements.txt \ | |
| -r requirements.txt | |
| nosetests --with-xunit -v --xunit-file results.xml | |
| """ | |
| } | |
| finally { | |
| publishHTML(target: [allowMissing: true, | |
| alwaysLinkToLastBuild: false, | |
| keepAll: true, | |
| reportDir: ".", | |
| reportFiles: "results.*", | |
| reportName: short_kind + " unittest results"]) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| stage("Unmodified (unit) testing") | |
| slack_stage("Unit testing unmodified ${project}", { | |
| parallel(unit_testers) | |
| }) | |
| stage("Finished") | |
| finish() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment