public static List <Step> ConvertToSteps( TemplateContext context, TemplateToken steps) { var stepsSequence = steps.AssertSequence($"job {PipelineTemplateConstants.Steps}"); var result = new List <Step>(); var nameBuilder = new ReferenceNameBuilder(); foreach (var stepsItem in stepsSequence) { var step = ConvertToStep(context, stepsItem, nameBuilder); if (step != null) // step = null means we are hitting error during step conversion, there should be an error in context.errors { if (step.Enabled) { result.Add(step); } } } // Generate context name if empty foreach (ActionStep step in result) { if (!String.IsNullOrEmpty(step.ContextName)) { continue; } var name = default(string); switch (step.Reference.Type) { case ActionSourceType.ContainerRegistry: var containerReference = step.Reference as ContainerRegistryReference; name = containerReference.Image; break; case ActionSourceType.Repository: var repositoryReference = step.Reference as RepositoryPathReference; name = !String.IsNullOrEmpty(repositoryReference.Name) ? repositoryReference.Name : PipelineConstants.SelfAlias; break; } if (String.IsNullOrEmpty(name)) { name = "run"; } nameBuilder.AppendSegment($"__{name}"); step.ContextName = nameBuilder.Build(); } return(result); }
//Note: originally was List<Step> but we need to change to List<ActionStep> to use the "Inputs" attribute internal static List <ActionStep> ConvertToSteps( TemplateContext context, TemplateToken steps) { var stepsSequence = steps.AssertSequence($"job {PipelineTemplateConstants.Steps}"); var result = new List <ActionStep>(); foreach (var stepsItem in stepsSequence) { var step = ConvertToStep(context, stepsItem); if (step != null) // step = null means we are hitting error during step conversion, there should be an error in context.errors { if (step.Enabled) { result.Add(step); } } } return(result); }