Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Artifact Filename using variables



  • I'm trying to use the package variable $TeamCityBuildNumber to specify an artifact name like Release_225.zip, where 225 is the $TeamCityBuildNumber

    I tried many variations and found an example in QA that suggested the following syntax.
    It doesn't work. I can't seem to find the answer in the documentation.

    Release_${TeamCityBuildNumber}.zip

    Product: BuildMaster
    Version: 5.0.6



  • Can you share the OtterScript of the plan you're using? That should work..



  • Sorry, I'm new to BuildMaster so I do not know how to provide the otterscript.
    I can see the JSON of the PIPELINE where I'm trying to use the variable.

    {
    "Name": "ISS",
    "Color": null,
    "Description": "ISS Pipeline",
    "EnforceStageSequence": true,
    "Stages": [
    {
    "Name": "Import",
    "Description": null,
    "Targets": [
    {
    "PlanName": null,
    "EnvironmentName": "Integration",
    "BuildImporterTemplate": {
    "persistedObject": "<Inedo.BuildMasterExtensions.TeamCity.TeamCityBuildImporterTemplate Assembly="TeamCity"><Properties ArtifactName="Release_${TeamCityBuildNumber}.zip" BuildConfigurationId="Branches_BuildCompile" BuildConfigurationDisplayName="" ArtifactNameLocked="True" BuildNumber="lastSuccessful" BranchName="" BranchNameLocked="True" ServerId="1" /></Inedo.BuildMasterExtensions.TeamCity.TeamCityBuildImporterTemplate>"
    },
    "ServerNames": [],
    "DefaultServerContext": 0
    }
    ],
    "Gate": {
    "UserApprovals": [],
    "GroupApprovals": [],
    "AutomaticApprovals": []
    },
    "PostDeploymentPlan": null,
    "PostDeploymentEventListeners": [],
    "AutoPromote": false
    },
    {
    "Name": "Integration",
    "Description": null,
    "Targets": [
    {
    "PlanName": "Deploy ISS",
    "EnvironmentName": "Integration",
    "BuildImporterTemplate": null,
    "ServerNames": [],
    "DefaultServerContext": 0
    }
    ],
    "Gate": {
    "UserApprovals": [],
    "GroupApprovals": [],
    "AutomaticApprovals": []
    },
    "PostDeploymentPlan": null,
    "PostDeploymentEventListeners": [],
    "AutoPromote": false
    },
    {
    "Name": "Testing",
    "Description": null,
    "Targets": [
    {
    "PlanName": "Deploy ISS",
    "EnvironmentName": "Testing",
    "BuildImporterTemplate": null,
    "ServerNames": [],
    "DefaultServerContext": 0
    }
    ],
    "Gate": {
    "UserApprovals": [],
    "GroupApprovals": [],
    "AutomaticApprovals": []
    },
    "PostDeploymentPlan": null,
    "PostDeploymentEventListeners": [],
    "AutoPromote": false
    },
    {
    "Name": "Production",
    "Description": null,
    "Targets": [
    {
    "PlanName": "Deploy ISS",
    "EnvironmentName": "Production",
    "BuildImporterTemplate": null,
    "ServerNames": [],
    "DefaultServerContext": 0
    }
    ],
    "Gate": {
    "UserApprovals": [],
    "GroupApprovals": [],
    "AutomaticApprovals": []
    },
    "PostDeploymentPlan": null,
    "PostDeploymentEventListeners": [],
    "AutoPromote": false
    }
    ],
    "PostDeploymentOptions": {
    "CreateRelease": true,
    "CancelReleases": false,
    "DeployRelease": true
    }
    }



  • Ah, great, thanks. that makes sense!

    Basically the issue is that you're using a "Build Importer" step, and those don't use variable replacement; in v5, we are planning to move away from the “build importer” concept, in favor of using just a regular “plan” that has the operation/operations necessary to import a build/package. Using a plan to import will also allow you to trigger TC builds, import any number of artifacts, etc.

    Unfortunately, we haven't converted the TeamCity actions (legacy/v4 plans) into operations (OtterScript/v5); see KB#1118 for more info on the differences.

    In the mean time, the best bet will be to use a Legacy Plan that has the Import TeamCity Action. We will convert these to operations soon, which will make them easier to use in the OtterScript/v5 plans.

    Best,
    Alana



  • How do I create a Legacy Plan in 5.0? I do not see an option for this.



  • This is only possible from the UI if you already have a legacy plan; however you can just issue the following SQL Command to the BuildMaster database to enable this:

    INSERT INTO [DeploymentPlans] ([DeploymentPlan_Name] ,[AllowLocalChanges_Indicator],[OtterScript_Bytes] ,[Application_Id])
    VALUES ('Test', 'Y', NULL, NULL)


  • I'm using version 5.2.3 (Build 3), $TeamCityBuildNumber still doesn't work as part of artifact name. It raises error:

    Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
    at Inedo.BuildMaster.BuildMasterVariableEvaluationContext.TryEvaluateFunction(RuntimeVariableName functionName, IList`1 arguments)
    at Inedo.ExecutionEngine.Variables.VariableTextValue.Evaluate(IVariableEvaluationContext context)
    at Inedo.ExecutionEngine.Variables.ProcessedString.Evaluate(IVariableEvaluationContext context)
    at Inedo.BuildMaster.Windows.ServiceApplication.Executions.PlanExecuter.DeploymentPlanExecuter.EvaluateExpressionAsync(String expression, IExecuterContext context)
    at Inedo.ExecutionEngine.Executer.ExecuterThread.<ExecuteAsync>d__45.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Inedo.ExecutionEngine.Executer.ExecuterThread.<ExecuteNextAsync>d__34.MoveNext()

    Once I remove $TeamCityBuildNumber from the arfact name, it works through. I suspect the variable is not available for the TeamCity::Import-Artifact operation.

    Any advise?



  • The variable replacement happens outside the Operation, but that's not the error i would expect.

    Can you share your entire OtterScript ?

    Can you also do a "Log-Information `$TeamCityBuildNumber is $TeamCityBuildNumber;" beforehand to test if the variable is available?



  • Logged the variable beforehand, same error happened. Here is my script:

    ##AH:UseTextMode
    template Import_Build_Template_2
    {
        # Queue and import build
        with retry = 5
        {
            Log-Debug TeamCityBuildNumber = $TeamCityBuildNumber;
    
            TeamCity::Import-Artifact
            (
                Artifact: Release.zip,
                Project: TestProject,
                BuildConfiguration: Build,
                Branch: bm,
                Credentials: teamcity,
                Server: $tc_server,
                UserName: $tc_un,
                Password: $tc_pd
            );
        }
    }


  • Error message:

    Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
    at Inedo.BuildMaster.BuildMasterVariableEvaluationContext.TryEvaluateFunction(RuntimeVariableName functionName, IList`1 arguments)
    at Inedo.ExecutionEngine.Variables.VariableTextValue.Evaluate(IVariableEvaluationContext context)
    at Inedo.ExecutionEngine.Variables.ProcessedString.Evaluate(IVariableEvaluationContext context)
    at Inedo.BuildMaster.Windows.ServiceApplication.Executions.PlanExecuter.DeploymentPlanExecuter.EvaluateExpressionAsync(String expression, IExecuterContext context)
    at Inedo.ExecutionEngine.Executer.ExecuterThread.<ExecuteAsync>d__45.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    at Inedo.ExecutionEngine.Executer.ExecuterThread.<ExecuteNextAsync>d__34.MoveNext()



  • Unfortunately we're not able to diagnose this with the information you provided. That error really doesn't make sense in the place it's happening.

    Can you please submit a ticket with:

    • Configuration Variables defined at various levels (System, etc)
    • Plan as OtterScript
    • Pipeline as JSON
    • Full Execution log, including the full stack trace you sent


Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation