@@ -103,44 +103,44 @@ struct Args {
}
fn run_test(
- jenkins: &JenkinsBackend,
+ backend: &CIBackend,
project: &Project,
tag: &str,
branch_name: &str,
job: &Job,
) -> TestResult {
- let mut jenkins_params = Vec::<(&str, &str)>::new();
+ let mut params = Vec::<(&str, &str)>::new();
for (param_name, param_value) in &job.parameters {
// TODO(ajd): do this more neatly
debug!("Param name {}, value {}", ¶m_name, ¶m_value);
- jenkins_params.push((param_name, param_value));
+ params.push((param_name, param_value));
}
- jenkins_params.push((&job.remote, &project.remote_uri));
- jenkins_params.push((&job.branch, tag));
+ params.push((&job.remote, &project.remote_uri));
+ params.push((&job.branch, tag));
info!("Starting job: {}", &job.title);
- let res = jenkins
- .start_test(&job.job, jenkins_params)
- .unwrap_or_else(|err| panic!("Starting Jenkins test failed: {}", err));
+ let res = backend
+ .start_test(&job.job, params)
+ .unwrap_or_else(|err| panic!("Starting test failed: {}", err));
debug!("{:?}", &res);
let build_handle_real;
loop {
- let build_handle = jenkins.get_build_handle(&res);
+ let build_handle = backend.get_build_handle(&res);
if let Ok(handle) = build_handle {
build_handle_real = handle;
break;
} // TODO: Handle error
}
debug!("Build URL: {}", build_handle_real);
- jenkins.wait_build(&build_handle_real).unwrap(); // TODO: Error correctly
- let mut test_result = jenkins.get_build_result(&build_handle_real).unwrap();
- info!("Jenkins job for {}/{} complete.", branch_name, job.title);
+ backend.wait_build(&build_handle_real).unwrap(); // TODO: Error correctly
+ let mut test_result = backend.get_build_result(&build_handle_real).unwrap();
+ info!("Test job for {}/{} complete.", branch_name, job.title);
if test_result == TestState::Fail && job.warn_on_fail {
test_result = TestState::Warning;
}
TestResult {
- description: match jenkins.get_description(&build_handle_real, &job.parameters) {
+ description: match backend.get_description(&build_handle_real, &job.parameters) {
Some(description) => Some(description),
None => Some(
format!("Test {} on branch {}", job.title, branch_name.to_string()).to_string(),
@@ -148,7 +148,7 @@ fn run_test(
},
state: test_result,
context: Some(job.title.replace("/", "_")),
- target_url: Some(jenkins.get_results_url(&build_handle_real, &job.parameters)),
+ target_url: Some(backend.get_results_url(&build_handle_real, &job.parameters)),
}
}
Make run_test() generic on the CIBackend trait rather than Jenkins specific. Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> --- src/main.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)