Duplicate Artifacts being Created

I am working on a deployment where we need produce an artifact (a DDL script to be run separately by an administrator). However, what we are finding is that the file in question is displayed twice (each with a different link address).

The artifact is created by saving the output of a method call to a file and then passing it to New-OctopusArtifact:

Add-Type -Path "../OneOffice.Alerts.Subscription.ServiceModel.dll"
Write-Host "Generating trigger scripts..."
$TriggerOutput = [OneOffice.Alerts.Subscription.ServiceModel.Deploy]::OutputTriggerScripts()
if (Test-Path .\SourceTriggers.sql)
{
	Remove-Item .\SourceTriggers.sql
}
Set-Content .\SourceTriggers.sql $TriggerOutput	
if (Test-Path .\SourceTriggers.sql)
{
	Write-Host "Creating new artifact"
	New-OctopusArtifact -Path ".\SourceTriggers.sql" -Name "Oracle Triggers"
}
Write-Host "Successfully generated triggers"

As you can see, we are logging the creation of the new artifact. Even though the message “Creating new artifact” only appears once two links appear in the Artifacts section.

ServerTasks-13280.log.txt (15 KB)

HI,

Thanks for reaching out!

It seems like you are running this script once from David's Machine and another time from `APP-DEV-03, which explains the duplicate artifacts

From Davis’s Machine

                  |     Success: David's Machine
09:50:21   Verbose  |       Octopus Server version: 3.3.23+Branch.master.Sha.b40b81a99f1dd143e64ea50818f1c15e419a91bb
09:50:22   Verbose  |       Octopus Deploy: Calamari version 3.3.29+Branch.master.Sha.2bd6efcee8e1a354bf6e8c3bb7d727e98957b320
09:50:22   Info     |       Extracting package: C:\Octopus\Packages\OneOffice.Alerts.Subscription\OneOffice.Alerts.Subscription.1.0.1-beta0001.nupkg
09:50:24   Info     |       Substituting variables in: C:\Octopus\Work\20160809085021-139\scripts\Generate-Source-Triggers.ps1
09:50:27   Verbose  |       Name                           Value
09:50:27   Verbose  |       ----                           -----
09:50:27   Verbose  |       PSVersion                      4.0
09:50:27   Verbose  |       WSManStackVersion              3.0
09:50:27   Verbose  |       SerializationVersion           1.1.0.1
09:50:27   Verbose  |       CLRVersion                     4.0.30319.42000
09:50:27   Verbose  |       BuildVersion                   6.3.9600.17400
09:50:27   Verbose  |       PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
09:50:27   Verbose  |       PSRemotingProtocolVersion      2.2
09:50:27   Info     |       Generating trigger scripts...
09:50:27   Info     |       Creating new artifact
09:50:28   Info     |       Successfully generated triggers
09:50:28   Verbose  |       Collecting artifact Oracle Triggers

From APP-DEV-03

                    |     Success: APP-DEV-03
09:50:21   Verbose  |       Octopus Server version: 3.3.23+Branch.master.Sha.b40b81a99f1dd143e64ea50818f1c15e419a91bb
09:50:25   Verbose  |       Octopus Deploy: Calamari version 3.3.29+Branch.master.Sha.2bd6efcee8e1a354bf6e8c3bb7d727e98957b320
09:50:25   Info     |       Extracting package: C:\Octopus\Packages\OneOffice.Alerts.Subscription\OneOffice.Alerts.Subscription.1.0.1-beta0001.nupkg
09:50:27   Info     |       Substituting variables in: C:\Octopus\Work\20160809085021-140\scripts\Generate-Source-Triggers.ps1
09:50:28   Verbose  |       Name                           Value
09:50:28   Verbose  |       ----                           -----
09:50:28   Verbose  |       PSVersion                      4.0
09:50:28   Verbose  |       WSManStackVersion              3.0
09:50:28   Verbose  |       SerializationVersion           1.1.0.1
09:50:28   Verbose  |       CLRVersion                     4.0.30319.42000
09:50:28   Verbose  |       BuildVersion                   6.3.9600.17400
09:50:28   Verbose  |       PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
09:50:28   Verbose  |       PSRemotingProtocolVersion      2.2
09:50:29   Info     |       Generating trigger scripts...
09:50:29   Info     |       Creating new artifact
09:50:29   Info     |       Successfully generated triggers
09:50:29   Verbose  |       Collecting artifact Oracle Triggers

Are you trying to create an artifact per target or just a single artifact per deployment? If its the latter, you might wanna execute the artifact creation script from the Octopus Server instead of from a specific Tentacle/Target.

Thanks,
Dalmiro

Hi Dalmiro,

I want to create one artifact per deployment. The thing is, the Generate SourceTriggers step is set to run on the Octopus Server. What I notice is that it is set to run on behalf of the Service role - and both David’s machine and APP-DEV-03 have these roles.

So, is the expected behaviour that even though the script is set to run on the Octopus Server it will run for each environment with the specified role?

Hi David,

That is the expected behavior yeah. The script step set up to run from the Octopus Server on behalf of machines with role “x” will run once per machine with that role.

If you want it to run only once then you’ll need to remove the role scope from that script step. If you were trying to use the role to make use of some variables scoped to it, scope those variables to that step instead.

Thanks,
Dalmiro

Notice:

This issue has been closed due to inactivity. If you encounter the same or a similar issue and require help, please open a new discussion (if we asked for logs or extra details in this thread, consider including them in the new thread). If you are the creator of this thread and believe it should not be closed let us know via our support email.