Exemple #1
0
        /// <summary>
        /// Deserialize an Azure DevOps Pipeline with a simple trigger/ string[] and simple variable list/ Dictionary<string, string>
        /// </summary>
        /// <param name="yaml">yaml to convert</param>
        /// <returns>Azure DevOps Pipeline with simple trigger and complex variables</returns>
        public static AzurePipelinesRoot <string[], AzurePipelines.Variable[]> DeserializeSimpleTriggerAndComplexVariables(string yaml)
        {
            yaml = CleanYamlBeforeDeserialization(yaml);
            AzurePipelinesRoot <string[], AzurePipelines.Variable[]> azurePipeline = GenericObjectSerialization.DeserializeYaml <AzurePipelinesRoot <string[], AzurePipelines.Variable[]> >(yaml);

            return(azurePipeline);
        }
Exemple #2
0
        public static string Serialize(GitHubActionsRoot gitHubActions, List <string> variableList = null, string matrixVariableName = null)
        {
            string yaml = GenericObjectSerialization.SerializeYaml <GitHubActionsRoot>(gitHubActions);

            yaml = ProcessGitHubActionYAML(yaml, variableList, matrixVariableName);

            return(yaml);
        }
Exemple #3
0
        public static string SerializeJob(GitHubActions.Job gitHubActionJob, List <string> variableList = null)
        {
            string yaml = GenericObjectSerialization.SerializeYaml <GitHubActions.Job>(gitHubActionJob);

            yaml = ProcessGitHubActionYAML(yaml, variableList);
            yaml = StepsPostProcessing(yaml);

            return(yaml);
        }
Exemple #4
0
        private static GitHubActionsRoot DeserializeGitHubActionsYaml(string yaml)
        {
            //Fix some variables that we can't use for property names because the - character is not allowed or it's a reserved word (e.g. if)
            yaml = yaml.Replace("runs-on", "runs_on");
            yaml = yaml.Replace("if", "_if");
            yaml = yaml.Replace("timeout-minutes", "timeout_minutes");
            yaml = yaml.Replace("pull-request", "pull_request");
            yaml = yaml.Replace("branches-ignore", "branches_ignore");
            yaml = yaml.Replace("paths-ignore", "paths_ignore");
            yaml = yaml.Replace("tags-ignore", "tags_ignore");
            yaml = yaml.Replace("max-parallel", "max_parallel");
            yaml = yaml.Replace("ref", "_ref");

            return(GenericObjectSerialization.DeserializeYaml <GitHubActionsRoot>(yaml));
        }
Exemple #5
0
        /// <summary>
        /// Deserialize an Azure DevOps Pipeline with a complex trigger and simple variable list
        /// </summary>
        /// <param name="yaml">yaml to convert</param>
        /// <returns>Azure DevOps Pipeline with complex trigger and simple variables</returns>
        public static AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > DeserializeComplexTriggerAndSimpleVariables(string yaml)
        {
            AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > azurePipeline = null;

            try
            {
                yaml          = CleanYamlBeforeDeserialization(yaml);
                azurePipeline = GenericObjectSerialization.DeserializeYaml <AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > >(yaml);
            }
            catch (Exception)
            {
                Debug.WriteLine($"{nameof(DeserializeComplexTriggerAndSimpleVariables)} swallowed an exception, to be reviewed...");
                //Do nothing
            }
            return(azurePipeline);
        }
Exemple #6
0
        /// <summary>
        /// Deserialize an Azure DevOps Pipeline with a complex trigger and simple variable list
        /// </summary>
        /// <param name="yaml">yaml to convert</param>
        /// <returns>Azure DevOps Pipeline with complex trigger and simple variables</returns>
        public static AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > DeserializeComplexTriggerAndSimpleVariables(string yaml)
        {
            AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > azurePipeline = null;

            try
            {
                yaml          = CleanYamlBeforeDeserialization(yaml);
                azurePipeline = GenericObjectSerialization.DeserializeYaml <AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > >(yaml);
            }
            catch (Exception ex)
            {
                ConversionUtility.WriteLine($"{nameof(DeserializeComplexTriggerAndSimpleVariables)} swallowed an exception: " + ex.Message, true);
                //Do nothing
            }
            return(azurePipeline);
        }
Exemple #7
0
        /// <summary>
        /// Deserialize an Azure DevOps Pipeline with a complex trigger and complex variable list
        /// </summary>
        /// <param name="yaml">yaml to convert</param>
        /// <returns>Azure DevOps Pipeline with complex trigger and complex variables</returns>
        public static AzurePipelinesRoot <AzurePipelines.Trigger, AzurePipelines.Variable[]> DeserializeComplexTriggerAndComplexVariables(string yaml)
        {
            //DANGER WILL ROBINSON - DANGER
            //Unlike the other deserializers, we need to leave this last error handler off - so that errors can be returned to the client, where as the others can fail so that they can try the next deserializer method.
            AzurePipelinesRoot <AzurePipelines.Trigger, AzurePipelines.Variable[]> azurePipeline = null;

            //try
            //{
            yaml          = CleanYamlBeforeDeserialization(yaml);
            azurePipeline = GenericObjectSerialization.DeserializeYaml <AzurePipelinesRoot <AzurePipelines.Trigger, AzurePipelines.Variable[]> >(yaml);
            //}
            //catch (Exception)
            //{
            //    //Do nothing
            //}
            return(azurePipeline);
        }
Exemple #8
0
        /// <summary>
        /// Deserialize an Azure DevOps Pipeline with a complex trigger and simple variable list
        /// </summary>
        /// <param name="yaml">yaml to convert</param>
        /// <returns>Azure DevOps Pipeline with complex trigger and simple variables</returns>
        public static AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > DeserializeComplexTriggerAndSimpleVariables(string yaml)
        {
            yaml = CleanYamlBeforeDeserialization(yaml);
            AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > azurePipeline = GenericObjectSerialization.DeserializeYaml <AzurePipelinesRoot <AzurePipelines.Trigger, Dictionary <string, string> > >(yaml);

            return(azurePipeline);
        }