Added a check on pipeline retry/creation in case the user doesn't have sufficient rights

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2022-06-03 22:49:07 +02:00
parent be11082b07
commit 32ef9027fd
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283

View File

@ -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<Pipeline>;
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);
}