f2calv / yamlizr

Azure DevOps Designer-to-YAML Pipeline CLI CodeGen Tool w/GitHub Actions Generation
MIT License
69 stars 16 forks source link

Null pointer exception #177

Open AlexNek opened 1 year ago

AlexNek commented 1 year ago

Key

Describe the bug Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ at CasCap.Utilities.YamlPipelineGenerator.GenBuildStage() in //src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs:line 112 at CasCap.Utilities.YamlPipelineGenerator.GenPipeline() in //src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs:line 67 at CasCap.Commands.GenerateCommand.<>cDisplayClass31_4.gProcessDefinition|16(BuildDefinition buildDefinition) in //src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs:line 241 at CasCap.Commands.GenerateCommand.OnExecuteAsync() in //src/CasCap.DevOpsYamlizrCli/Commands/GenerateCommand.cs:line 223 at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken) at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>cDisplayClass0_0.<b0>d.MoveNext() --- End of stack trace from previous location --- at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at CasCap.Program.Main(String[] args) in /_/src/CasCap.DevOpsYamlizrCli/Program.cs:line 33 at CasCap.Program.

(String[] args)

Note: It is not only one place as I try to use source code before that time. Did you use the latest API Call? A lot of standard Releases "read" too little values and other parts. For sample, I can see on azure 12 variables but ReleaseDefinition class return only 4.

f2calv commented 1 year ago

Please update to 2.0.1 and let me know if still a problem.

daj102 commented 1 year ago

I have just installed 2.0.1 and I'm getting a similar issue; I do have Task Groups in my release pipelines and I'm getting this error when I run the tool:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object. at CasCap.Utilities.YamlPipelineGenerator.GenSteps(Template template, Dictionary2 inputs) in //src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs:line 390 at CasCap.Utilities.YamlPipelineGenerator.GetSteps(Template template, IDictionary`2 inputs) in //src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs:line 386 `

That line refers to task group values:

var filename = $"{template.taskGroup.Name.Sanitize()}-v{template.taskGroup.Version.Major}.yml";

and all my task group names have spaces in ... they do have versions similar to "1.*" so it could be that too.

daj102 commented 1 year ago

Oddly, putting in the --inline switch allows it to work, but it doesn't put the task groups inline in the pipelines - it still generates the task groups in separate files...

f2calv commented 1 year ago

I have no errors in my own integration tests (including with task groups) so I can only suggest that you debug this issue for yourself;

  1. Clone the repo and open in latest Visual Studio.
  2. Set CasCap.DevOpsYamlizrCli project as the start-up project.
  3. Edit the launchSettings.json file with your own details;
    {
    "profiles": {
    "yamlizr": {
      "commandName": "Project",
      "commandLineArgs": "generate -pat 1111111122222222233333334444444444555555 -org https://dev.azure.com/some_org -proj my_proj -out c:/temp/myoutputfolder"
    }
    }
    }
  4. Hit Play (in Debug mode) and please create a PR and/or post to this thread when you find the issue.

Note: you can also can install the prior version;

#install last known stable version
dotnet tool update yamlizr --version 1.0.21

#run with old-style arguments (org is a name, not a Uri)
yamlizr generate -pat 1111111122222222233333334444444444555555 -org some_org -proj my_proj -out c:/temp/myoutputfolder
flcdrg commented 4 months ago

Also getting this error

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.0:00 / 00:00:00
   at CasCap.Utilities.YamlPipelineGenerator.GenSteps(Template template, Dictionary`2 inputs) in /_/src/CasCap.Apis.AzureDevOps/Utilities/YamlPipelineGenerator.cs:line 390

One thing that is a possible culprit - the pipeline references an extension that has been removed