Add Azure Devops as a -format option. (#3335)

This commit is contained in:
StefanBRas 2023-03-06 03:48:39 +01:00 committed by GitHub
parent 5d8591fec4
commit 30c71dc59a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 35 additions and 6 deletions

View file

@ -374,6 +374,33 @@ impl Printer {
writeln!(stdout, "{label}")?;
}
}
SerializationFormat::Azure => {
// Generate error logging commands for Azure Pipelines format.
// See https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#logissue-log-an-error-or-warning
for message in &diagnostics.messages {
let label = format!(
"{}{}{}{}{}{} {} {}",
relativize_path(Path::new(&message.filename)),
":",
message.location.row(),
":",
message.location.column(),
":",
message.kind.rule().noqa_code(),
message.kind.body(),
);
writeln!(
stdout,
"##vso[task.logissue type=error\
;sourcepath={};linenumber={};columnnumber={};code={};]{}",
message.filename,
message.location.row(),
message.location.column(),
message.kind.rule().noqa_code(),
label,
)?;
}
}
}
stdout.flush()?;