Octopus Prompted variable API

resolved
usability
server
known
(Mohitmishra Mishra1989) #1

do we have any API from where i can check the value of prompted variable for a particular deployment

(Paul Calvert) #3

Hi @mohitmishra.mishra1989,

Thanks for getting in touch!

This is possible using the API.
If this is a one time check, then the easiest option would be to use https:///api/deployments to find the specific deployment and then check the Links section for the Variables URL e.g.

{
      "Id": "Deployments-182",
      "ReleaseId": "Releases-224",
      "ChannelId": "Channels-22",
      "DeploymentProcessId": "deploymentprocess-Projects-21-s-39-MQZ9N",
      "Changes": [
        {
          "Version": "2019.10.18",
          "ReleaseNotes": "",
          "BuildInformation": [],
          "WorkItems": [],
          "Commits": []
        }
      ],
      "ChangesMarkdown": "\r\n**Release 2019.10.18**\r\n\r\n\r\n\r\n",
      "EnvironmentId": "Environments-1",
      "TenantId": null,
      "ForcePackageDownload": false,
      "ForcePackageRedeployment": false,
      "SkipActions": [],
      "SpecificMachineIds": [],
      "ExcludedMachineIds": [],
      "ManifestVariableSetId": "variableset-Deployments-182",
      "TaskId": "ServerTasks-739",
      "ProjectId": "Projects-21",
      "UseGuidedFailure": false,
      "Comments": null,
      "FormValues": {},
      "QueueTime": null,
      "QueueTimeExpiry": null,
      "Name": "Deploy to Dev (#2)",
      "Created": "2020-02-14T10:17:52.630+00:00",
      "SpaceId": "Spaces-1",
      "TentacleRetentionPeriod": {
        "Unit": "Days",
        "QuantityToKeep": 0,
        "ShouldKeepForever": true
      },
      "DeployedBy": "PaulCalvert",
      "DeployedById": "Users-1",
      "FailureEncountered": false,
      "DeployedToMachineIds": [],
      "Links": {
        "Self": "/api/Spaces-1/deployments/Deployments-182",
        "Release": "/api/Spaces-1/releases/Releases-224",
        "Environment": "/api/Spaces-1/environments/Environments-1",
        "Project": "/api/Spaces-1/projects/Projects-21",
        "Task": "/api/tasks/ServerTasks-739",
        "Web": "/app#/Spaces-1/deployments/Deployments-182",
        "Artifacts": "/api/Spaces-1/artifacts?regarding=Deployments-182",
        "Interruptions": "/api/Spaces-1/interruptions?regarding=Deployments-182",
        "DeploymentProcess": "/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-21-s-39-MQZ9N",
        "Variables": "/api/Spaces-1/variables/variableset-Deployments-182"
      }

This variable set will include all variables used for that deployment, including any prompted ones.
e.g.

{
      "Id": "4004d04f-8452-d5d2-ae0e-888d6bb05d5e",
      "Name": "Prompt",
      "Value": "TestPrompt",
      "Description": null,
      "Scope": {
        "Project": [
          "Projects-21"
        ],
        "User": [
          "True"
        ]
      },
      "IsEditable": false,
      "Prompt": {
        "Label": "",
        "Description": "",
        "Required": false,
        "DisplaySettings": {}
      },
      "Type": "String",
      "IsSensitive": false
    },

If this is something that you want to check on a regular basis then you may want to use the octopus.client to create a script to retrieve the required information.
We have a repository of scripts that should help get you started: https://github.com/OctopusDeploy/OctopusDeploy-Api

I hope this helps, please let me know if you have any further questions.

Best regards,
Paul

(Mohitmishra Mishra1989) #4

I couldn’t find variables link in deployments API.

“Links”: {
“Self”: “/Octopus/api/Spaces-1/deployments/Deployments-74761”,
“Release”: “/Octopus/api/Spaces-1/releases/Releases-33023”,
“Environment”: “/Octopus/api/Spaces-1/environments/Environments-241”,
“Project”: “/Octopus/api/Spaces-1/projects/Projects-230”,
“Task”: “/Octopus/api/tasks/ServerTasks-149822”,
“Web”: “/Octopus/app#/Spaces-1/deployments/Deployments-74761”,
“Artifacts”: “/Octopus/api/Spaces-1/artifacts?regarding=Deployments-74761”,
“Interruptions”: “/Octopus/api/Spaces-1/interruptions?regarding=Deployments-74761”,
“DeploymentProcess”: “/Octopus/api/Spaces-1/deploymentprocesses/deploymentprocess-Projects-230-s-348-KTPDL”
}
}

Note: Current Version of octopus is v2019.12.0.LTS

(Paul Calvert) #5

Hi @mohitmishra.mishra1989,

I’ve just double checked this and we do only retain this information for a set period, so it won’t be possible to retrieve the prompted values for some older deployments unfortunately.

You should find the variables link is available for more recent deployments and any new ones.

Regards,
Paul