Hello :)
During my work with Nuke, I've come across some places where increased extensibility would be a benefit. That's why I've developed an approach with custom steps. I would like to share with you my implementation.
As in shown in Usage Example, I think it is a good idea to add possibility to write own custom steps and address them by attributes. Considering the current architecture of Nuke, it gives a great extensibility without big amount of changes.
I've written the usage example from the top of my head because at this moment I do not have access to my code.
Usage Example
public class TestBuild : NukeBuild
{
[AzureDevOpsDownloadSecureFileStep("securefile.zip")]
public Target Test => _ => _
.DependsOn(Compile)
.Produces(TestResultDirectory / "*.trx")
.Produces(TestResultDirectory / "*.xml")
.Partition(2);
}
// User provided implementations
class AzureDevOpsDownloadSecureFileStepAttribute : AzurePipelineStepAttribute
{
public AzureDevOpsDownloadSecureFileStepAttribute(string fileName)
{
FileName = fileName;
}
public string FileName { get; }
public override AzurePipelinesStep Get()
{
return new AzureDevOpsDownloadSecureFileStep(FileName);
}
}
class AzureDevOpsDownloadSecureFileStep : AzurePipelinesStep
{
public AzureDevOpsDownloadSecureFileStep(string fileName)
{
FileName = fileName;
}
public string FileName { get; }
public override void Write(CustomFileWriter writer)
{
writer.WriteLine("- task: DownloadSecureFile@1");
using (writer.Indent())
{
writer.WriteLine("inputs:");
using (writer.Indent())
{
writer.WriteLine($"secureFile: '{FileName}'");
}
}
}
}
Alternative
Alternative is to write all YAML pipelines by hand, but I do not want that as in a team not everybody must be fluent with .yml files. That's why I like the idea to generate as much pipeline code as possible by Nuke.
Description
Hello :) During my work with Nuke, I've come across some places where increased extensibility would be a benefit. That's why I've developed an approach with custom steps. I would like to share with you my implementation. As in shown in Usage Example, I think it is a good idea to add possibility to write own custom steps and address them by attributes. Considering the current architecture of Nuke, it gives a great extensibility without big amount of changes.
I've written the usage example from the top of my head because at this moment I do not have access to my code.
Usage Example
Alternative
Alternative is to write all YAML pipelines by hand, but I do not want that as in a team not everybody must be fluent with
.yml
files. That's why I like the idea to generate as much pipeline code as possible by Nuke.Could you help with a pull-request?
Yes [#1407]