How and where does Script Content get stored?

When I add a Run Script step to my project and I set the Script Source to Source Code Octopus allows me to enter my powershell code directly into the Script Content box.

Where/how exactly does that script content get stored? Does it go in the database? If so which tables?


Thanks for getting in touch. The script gets stored as just another property on the deployment step. So it would go into the DeploymentProcess table.

You can see the deployment process data for a project by going to /api/deploymentprocesses/deploymentprocess-Projects-21 where Projects-21 is the ID of the project. To get the ID, get the “slug” of the project from the Web UI URL (/app#/projects/<slug>/process) and go to /api/projects/<slug>.

If you let me know what you want to achieve, I’d be happy to advise on the best way to do that. We don’t support direct database access and recommend going through the API.

I want to get access to it for a couple of reasons.

The biggest one is that I would like to devise a tool of some sorts that would show me where my variables dependencies are in my deployments.

Thats one piece of the puzzle.


Right. That makes sense. The C# script below uses the Octopus.Client package to get the script from all script steps:

var endpoint = new OctopusServerEndpoint("http://localhost", "APIKEY");
var repository = new OctopusRepository(endpoint);
repository.Users.SignIn("Admin", "Password01!");

var project = repository.Projects.FindByName("Script");
var process = repository.DeploymentProcesses.Get(project.DeploymentProcessId);

var scripts = from s in process.Steps
			  from a in s.Actions
			  where a.ActionType == "Octopus.Script"
			  select a.Properties["Octopus.Action.Script.ScriptBody"];

You might also be interested in this issue I started working on this week. It will allow you to extract all the variables used in a script or file.

Rob W

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