diff --git a/src/gitlab_controller.rs b/src/gitlab_controller.rs index 463ab32..79fb188 100644 --- a/src/gitlab_controller.rs +++ b/src/gitlab_controller.rs @@ -121,7 +121,7 @@ pub fn retry_pipeline(host: &str, token: &str, project: &Project) { warn!("{:?} has no pipeline, ignoring.", project); return; } - let res: Pipeline; + let res: Option; if pipeline.clone().unwrap().status == "success" { debug!("Latest pipeline for {:?} has a 'success' status, creating another one.", project); @@ -129,7 +129,7 @@ pub fn retry_pipeline(host: &str, token: &str, project: &Project) { .project(project.name.clone()) .ref_(project.ref_.clone()) .build().unwrap(); - res = endpoint.query(&client).unwrap(); + res = endpoint.query(&client).ok(); } else { debug!("Latest pipeline status for {:?} wasn't a success, retrying.", project); @@ -137,8 +137,12 @@ pub fn retry_pipeline(host: &str, token: &str, project: &Project) { .project(project.name.clone()) .pipeline(pipeline.unwrap().id) .build().unwrap(); - res = endpoint.query(&client).unwrap(); + res = endpoint.query(&client).ok(); + } + if res.is_none() { + error!("Could not retry/create a new pipeline for project {:?}. Ignoring.", project); + } else { + debug!("API answer was {:?}.", res.unwrap()); } - debug!("API answer was {:?}.", res); }