I am working with one of our teams to replace their ‘Deploy a Package’ step with a ‘Run a Script’ step (with referenced package) to run the project on a single worker.
Here is the test setup:
1. Download & Extract DACPAC Package
Script: ?
We want this script to perform an identical function of the “Deploy a Package” step.
Referenced Packages: GIEQ.TestDBScripts
Enabled to extract package during deployment.
2. SQL - Execute SQL Script with SQL or Windows Authentication
DACPAC Package Extract Step Name: Using the above “Download & Extract DACPAC Package” step.
In their current setup using “Deploy a Package” step, we see these results in the package extraction:
Deploying package: E:\Octopus\Tentacle\Files\GIEQ.TestDBScripts@S2021.1.22.1@E0E416AC37463341A6233837CEC94358.nupkg
Extracting package to: E:\Octopus\Tentacle\DEV\GIEQ.TestDBScripts\2021.1.22.1
Extracted 1 files
We want to avoid using a custom install directory–just the default. From what I can see, they do not specify the extraction location. In this case, because we are deploying to a worker, the default extraction location should be:
E:\Octopus\Applications\NJ1DEVSQL21_Worker_01\DEV
I’ve played around with a script, and see it being extracted to the work folder, but never to the applications folder.
Your assessment is correct, when you have a package referenced on a script step with a worker, it will extract to the work directory for the deployment, which will get deleted after the deployment is finished. This folder is transient, so keep that in mind for your use case.
You should just need to run a cd command on the package name to get into that folder to work with the extracted files. So in step 2 before you do your work, start with cd packageName.
Please let me know if that helps or if we need to dig in deeper.
Sorry about the delay I was out of the office last week and the team was a bit slammed and couldn’t pick this up.
I took a look at the logs and my apologies for my initial suggestion. This format won’t work as the work directories get cleaned up between steps. Is there any reason you cant reference the package within the step doing the work and work with the extracted package in the same step?
If you want the file to be in the Applications folder, I think we have two ways we can go about this.
One, you could create a Tentacle on that machine so you can use Deploy a Package to get it to the Applications folder. The downside here is you will use an additional target of your target cap.
The other option if you want to continue to use workers is you could use that Download & Extract DACPAC Package step, and have the script step actually move the contents of the extracted directory to the Applications folder that you’d like it in.
You would reference the extracted path with this variable:
$directory = $OctopusParameters[“Octopus.Action[Download & Extract DACPAC Package].Output.Octopus.Action.Package[GIEQ.AARDVARKDBScripts].ExtractedPath”]
You could then use some logic to move the contents of that folder to the directory you wish the files to be in. For example : E:\Octopus\Applications\NJ1DEVSQL21_Worker_01\DEV\APPNAMEHERE\VERSIONHERE
Keep in mind that workers are not cleaned up by retention, so you would need to have a script step at the end to delete the contents of that folder.
Please let me know if you think that will work for your use case.