Ejemplo n.º 1
0
        private static void GenerateExecutionLineForStep(Step step, PipelineFile pipelineFile, LinkedList <Step> currentExecutionLine, ISet <string> pathsTaken = null)
        {
            if (pathsTaken == null)
            {
                pathsTaken = new HashSet <string>();
            }

            foreach (var preStepName in step.PreStepNames)
            {
                if (preStepName == step.Name)
                {
                    throw new StepSelfReferencesException($"Error! step \"{step.Name}\" references it self a a pre-step.");
                }

                var preStep = pipelineFile.Steps.SingleOrDefault(x => x.Name == preStepName);
                if (preStep == null)
                {
                    throw new StepNotDefinedException($"Error! step \"{step.Name}\" references pre-step \"{preStepName}\" which is not defined in the file.");
                }

                var path = string.Join("-->", step.Name, preStep.Name);
                if (pathsTaken.Contains(path))
                {
                    throw new StepCircularReferenceException($"Error! Circular step reference caused by \"{step.Name}\" referencing pre-step \"{preStep.Name}\" which ends up re-entroducing step \"{step.Name}\" and its pre-steps.");
                }

                pathsTaken.Add(path);

                GenerateExecutionLineForStep(preStep, pipelineFile, currentExecutionLine, pathsTaken);
            }

            currentExecutionLine.AddLast(step);
        }
Ejemplo n.º 2
0
        private PipelineFile ReadPipelineFileFrom(string pipelineFilePath)
        {
            var fileContent = _fileSystem.ReadFileContents(pipelineFilePath);

            return(PipelineFile.Parse(fileContent));
        }
Ejemplo n.º 3
0
        private static IEnumerable <Step> BuildExecutionPipelineFrom(IEnumerable <string> requestedSteps, PipelineFile pipelineFile)
        {
            var executionPipeline = new LinkedList <Step>();

            foreach (var step in requestedSteps)
            {
                var existingStep = pipelineFile.Steps.SingleOrDefault(x => x.Name == step);
                if (existingStep == null)
                {
                    throw new StepNotDefinedException($"Error! Requested step \"{step}\" is not defined in the file.");
                }

                GenerateExecutionLineForStep(existingStep, pipelineFile, executionPipeline);
            }

            // default to first step defined in file if nothing has been specified on command line
            if (executionPipeline.Count == 0)
            {
                executionPipeline.AddLast(pipelineFile.Steps.First());
            }

            return(executionPipeline);
        }
Ejemplo n.º 4
0
        private static Dictionary <string, string> BuildFinalVariablesFrom(IEnumerable <KeyValuePair <string, string> > variables, PipelineFile pipelineFile)
        {
            var finalVariables = new Dictionary <string, string>(variables);

            foreach (var(key, value) in pipelineFile.Variables)
            {
                if (!finalVariables.ContainsKey(key))
                {
                    finalVariables.Add(key, value);
                }
            }

            return(finalVariables);
        }