Project blocked with error "The resource was not found"

Hi
We have two projects that we can not open. When we try to open them we just get the error:
The resource ‘xxx’ was not found.
Where xxx is a package that does exist in our package repository.
I think that the problem has something to do with either Automatic Release Creation or Release Versioning pointing to a step that no longer references that package.
Can you help us remove those two projects? I can not even open them, let alone remove them.
:slight_smile:
/Cecilia

Hi @cecilia,

Thanks for reaching out and sorry to hear you’re having issues with your project.
You’re absolutely correct and I believe that the issue is due to the release versioning based on your description.

I’ll attach a powershell script in-line to this response that will reset the versioning strategy of a project back to default.
The script creates a new project, grabs the fresh versioning strategy, then PUTs it over the broken project, afterwards it then deletes the temporary new project.
In order to use the script, please take note of:

  • The Spaces-ID the broken project resides within.
  • A Project Group Name that exists on that space. (The default is fine.)
  • A Lifecycle Name that exists on that space. (The default is fine.)
  • The Projects-ID of the broken project(s).

If you’re unable to locate the projects-ID for the projects due to the error, but you know the name of the project, you can sort the Octopus Audit log under Configuration → Audit by project name, expanding any event relating to the project should display the projects-id.

Here is the script below, please add any details marked as user defined and run the script for each project you’re unable to access.

# Create Script Variables
$octopusUrl = "https://OctopusURL" #USER_DEFINED
$octopusAPIKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" #USER_DEFINED
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }

# Case Specific Variables | Customise Lifecycle Name and Project Group if necessary.
$spaceId = "Spaces-XX" #USER_DEFINED
$newProjectName = "Project_For_Template"
$newProjectDescription = "Project created for version template to fix broken references. Will be deleted after."
$projectGroupName = "Default Project Group" #USER_DEFINED
$lifecycleName = "Default lifecycle" #USER_DEFINED

# BROKEN PROJECT ID
$brokenProjectId = "Projects-XX" #USER_DEFINED

# Get Project Group Id
$projectGroup = (Invoke-RestMethod -Method Get "$octopusURL/api/$($spaceId)/projectgroups/all" -Headers $header) | Where-Object {$_.Name -eq $projectGroupName}

# Get Lifecycle Id
$lifeCycle = (Invoke-RestMethod -Method Get "$octopusURL/api/$($spaceId)/lifecycles/all" -Headers $header) | Where-Object {$_.Name -eq $lifecycleName}

# JSON Payload for template project
$jsonPayload = @{
    Name = $newProjectName
    ProjectGroupId = $projectGroup.Id
    LifeCycleId = $lifeCycle.Id
}

# Create new project
$newProject = Invoke-RestMethod -Method Post -Uri "$octopusURL/api/$($spaceId)/projects" -Body ($jsonPayload | ConvertTo-Json -Depth 10) -Headers $header

# Gather deployment settings template
$depTemplate = Invoke-RestMethod -Method Get -Uri "$octopusURL$($newProject.Links.DeploymentSettings)" -Headers $header

# Copy and modify template to match broken project
$newDepSettings = $depTemplate
$newDepSettings.Id = $newDepSettings.Id.replace($newProject.Id, $brokenProjectId)
$newDepSettings.ProjectId = $newDepSettings.ProjectId.replace($newProject.Id, $brokenProjectId)

# Determine deployment settings URL for broken project
$newUrl = $newProject.Links.DeploymentSettings.replace($newProject.Id, $brokenProjectId)

# Upload newly created default deployment settings to broken project
Invoke-RestMethod -Method Put -Uri "$octopusURL$($newUrl)" -Headers $header -Body ($newDepSettings | ConvertTo-Json -Depth 10)

# Delete Template Project
Invoke-RestMethod -Method Delete -Uri "$octopusURL/api/$($spaceId)/projects/$($newProject.Id)" -Headers $header

I hope this helps! Please let me know if you run into any issues with the script or if you have any questions or concerns.

Kind Regards,
Adam

1 Like

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