Nuget Octopus.Client not showing correct parameters in ActionTemplate

Hi,

I have defined a ActionTemplate via the webinterface of OctopusDeploy. In my C# app I use the actiontemplate to create steps. In the C# app I use the nuget Octopus.Client (4.46).
However it seems that not all the parameters are shown. However when I make adjustment to my actiontemplate and then restart the program, the parameters are shown. After restart of the application the parameters are gone again.
Doing a rest call (with the swagger interface) I see the correct parameters.

Are there issues with the Octopus.Client?

Cheers.

Hi there,

Thanks for getting in touch.

Would you be able to provide us with the code you are using in your C# app and also your step template (an export of it would be very useful) so that we can track down what is causing this issue.

Thank you and best regards,
Henrik

Hi Hendrik,

(Zie het bijgevoegde bestand: StepTemplate.json)

Thanks for the effort to contact me. Herewith the troubled StepTemplate.

Herewith also a part of the code, the code uses an existing process. That process contains a step (with the name TemplateStep and uses the troubled steptempate), all the generated steps are based on the template step.

Kind regards,

Barend Tempelman

OctopusRepository repo = new OctopusRepository(client);

ProjectResource project = repo.Projects.FindByName(“MyProject”);

DeploymentProcessResource process = repo.DeploymentProcesses.Get(project.DeploymentProcessId);

VariableSetResource varset = repo.VariableSets.Get(project.VariableSetId);

List environments = repo.Environments.FindAll();

DeploymentStepResource templateStep = process.Steps.Where(t => t.Name.Equals(“TemplateStepThatUsesTheTroubledStepTemplate”, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

if (templateStep == null)

{

MessageBox.Show("TemplateStep not found");

return null;

}

//create steps

assisoReadResult.GroupBy(x => StepFilter.GetMainStepName(x.StapName, x.TargetRoles)).Select(grp => new KeyValuePair<string, string>(grp.First().StapName, grp.First().TargetRoles)).ToList()

    .ForEach(r => stepResult.StepsToExecute.Add(new StepResult(StepFilter.GetMainStepName(r.Key, r.Value), r.Value)));

foreach (SqlStepTemplate item in assisoReadResult)

{

string databaseName = item.TemplateType == EStepTemplateType.SqlCreateLogin ? "master" : item.DatabaseName;

SubStep ss = new SubStep(item.StapName, item.DatabaseServerName, databaseName, item.GetCmdVariables, item.ScriptPad);

stepResult.AddToResult(ss, StepFilter.GetMainStepName(item.StapName, item.TargetRoles));

}

foreach (StepResult item in stepResult.StepsToExecute)

{

DeploymentStepResource nieuwe = new DeploymentStepResource();

nieuwe.Name = $"Uitvoeren scripts {item.TaskName}";

nieuwe.Condition = templateStep.Condition;

foreach (var prop in templateStep.Properties)

{

    if (prop.Key.Equals("Octopus.Action.TargetRoles"))

    {

        nieuwe.Properties.Add(prop.Key, new PropertyValueResource(item.MachineRoleName, prop.Value.IsSensitive));

    }

    else

    {

        nieuwe.Properties.Add(prop);

    }

}



foreach (var act in templateStep.Actions)

{

    DeploymentActionResource res = new DeploymentActionResource

    {

        Name = $"Uitvoeren scripts {item.TaskName}",

        ActionType = act.ActionType,

        CanBeUsedForProjectVersioning = act.CanBeUsedForProjectVersioning,

        IsDisabled = false,

        IsRequired = act.IsRequired,

        WorkerPoolId = act.WorkerPoolId,

        LastModifiedBy = "Tooltje",

        LastModifiedOn = DateTime.Now

    };

    bool isPropFound = false;

    foreach (var prop in act.Properties)

    {

        switch (prop.Key)

        {

			//I'll set my value here to the SqlCommandSet param, otherwise I just add the template from the TemplateStep

            case "SqlCommandSet":

                {

                    isPropFound = true;

                    res.Properties.Add(prop.Key, new PropertyValueResource(item.ToString(), false));

                    break;

                }

            default:

                {

                    res.Properties.Add(prop);

                    break;

                }

        }

    }

    //THIS IS MY FIX, IF THE PROPERTY IS NOT FOUND, I'LL ADD IT THE HARD WAY

    if (!isPropFound)

    { res.Properties.Add("SqlCommandSet", new PropertyValueResource(item.ToString(), false)); }

    foreach (var ex in act.ExcludedEnvironments)

    {

        res.ExcludedEnvironments.Add(ex);

    }

    foreach (var ex in act.Channels)

    {

        res.Channels.Add(ex);

    }

    foreach (var ex in act.TenantTags)

    {

        res.TenantTags.Add(ex);

    }

    nieuwe.Actions.Add(res);

}

process.Steps.Add(nieuwe);

}

repo.DeploymentProcesses.Modify(process);

Inactief details verbergen voor"Henrik Andersson" ---01/29/2019 03:48:13 AM---Hi there, Thanks for getting in touch.“Henrik Andersson” —01/29/2019 03:48:13 AM—Hi there, Thanks for getting in touch.

StepTemplate.json (2.99 KB)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.