### Download and run the sample Node.js project Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/deployments/node-js/node-on-linux.md Clone the sample project from GitHub, checkout the gulp branch, install dependencies, build, and start the application to ensure it runs correctly. ```bash git clone https://github.com/OctopusDeploy/octofxjs.git cd octofxjs/ git checkout gulp npm install ``` ```bash npm run build npm start ``` -------------------------------- ### Octopus Instance Output Example Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/octopus.server.exe-command-line/list-instances.md This is an example of the output when multiple Octopus instances are installed on a machine. It shows the instance name and the path to its configuration file. ```text Instance 'MyNewInstance' uses configuration 'C:\MyNewInstance\MyNewInstance.config'. Instance 'OctopusServer' uses configuration 'C:\Octopus\OctopusServer.config'. ``` -------------------------------- ### Create a Tenant with Octopus CLI Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-tenant-create.mdx This is a basic example of creating a tenant using the Octopus CLI. Ensure you have the CLI installed and configured to connect to your Octopus Deploy instance. ```bash octopus tenant create ``` -------------------------------- ### Create, install, and export a new certificate for a specific Tentacle instance Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/tentacle.exe-command-line/new-certificate.md This example demonstrates creating, installing, and exporting a new certificate for a specified Tentacle instance. It includes the instance name, the path for the exported PFX file, and the password for the PFX file. ```bash tentacle new-certificate --instance="MyNewInstance" --export-pfx="c:\temp\MyNewInstance.pfx" --pfx-password="$uper$ecretP@ssw0rd" ``` ```bash tentacle new-certificate --instance="MyNewInstance" --export-pfx="/tmp/MyNewInstance.pfx" --pfx-password="$uper$ecretP@ssw0rd" ``` -------------------------------- ### Create Go Script Action Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/scripts/create-script-step-scripts.include.md This Go example demonstrates creating a deployment step with a script action. It includes functions for authentication, retrieving spaces and projects, and updating deployment processes. ```go package main import ( "fmt" "log" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy" ) func main() { apiURL, err := url.Parse("https://your-octopus-url") if err != nil { log.Println(err) } APIKey := "API-YOUR-KEY" spaceName := "Default" projectName := "MyProject" stepName := "MyStep" scriptBody := "Write-Host \"Hello world\"" roleName := "MyRole" // Get reference to space space := GetSpace(apiURL, APIKey, spaceName) // Create client object client := octopusAuth(apiURL, APIKey, space.ID) // Get project project := GetProject(apiURL, APIKey, space, projectName) // Get deployment process deploymentProcess := GetDeploymentProcess(client, project) // Create new step object step := octopusdeploy.DeploymentStep{ Name: stepName, } step.Condition = octopusdeploy.DeploymentStepConditionTypeSuccess step.StartTrigger = octopusdeploy.DeploymentStepStartTriggerStartAfterPrevious step.PackageRequirement = octopusdeploy.DeploymentStepPackageRequirementLetOctopusDecide roleProperties := []octopusdeploy.PropertyValue{} roleProperty := octopusdeploy.PropertyValue{ IsSensitive: false, Value: roleName, } roleProperties = append(roleProperties, roleProperty) stepProperties := make(map[string][]octopusdeploy.PropertyValue) stepProperties["Octopus.Action.TargetRoles"] = roleProperties // Create action action := octopusdeploy.DeploymentAction{ IsDisabled: false, IsRequired: false, } action.IsDisabled = false action.IsRequired = false actionScriptBody := octopusdeploy.NewPropertyValue(scriptBody, false) actionProperties := make(map[string]octopusdeploy.PropertyValue) actionProperties["Octopus.Action.Script.ScriptBody"] = actionScriptBody action.Properties = actionProperties // Add action to step step.Actions = append(step.Actions, action) // Add to process deploymentProcess.Steps = append(deploymentProcess.Steps, step) client.DeploymentProcesses.Update(deploymentProcess) } func octopusAuth(octopusURL *url.URL, APIKey, space string) *octopusdeploy.Client { client, err := octopusdeploy.NewClient(nil, octopusURL, APIKey, space) if err != nil { log.Println(err) } return client } func GetSpace(octopusURL *url.URL, APIKey string, spaceName string) *octopusdeploy.Space { client := octopusAuth(octopusURL, APIKey, "") spaceQuery := octopusdeploy.SpacesQuery{ Name: spaceName, } // Get specific space object spaces, err := client.Spaces.Get(spaceQuery) if err != nil { log.Println(err) } for _, space := range spaces.Items { if space.Name == spaceName { return space } } return nil } func GetProject(octopusURL *url.URL, APIKey string, space *octopusdeploy.Space, projectName string) *octopusdeploy.Project { // Create client client := octopusAuth(octopusURL, APIKey, space.ID) projectsQuery := octopusdeploy.ProjectsQuery { Name: projectName, } // Get specific project object projects, err := client.Projects.Get(projectsQuery) if err != nil { log.Println(err) } for _, project := range projects.Items { if project.Name == projectName { return project } } return nil } func GetDeploymentProcess(client *octopusdeploy.Client, project *octopusdeploy.Project) *octopusdeploy.DeploymentProcess { deploymentProcess, err := client.DeploymentProcesses.GetByID(project.DeploymentProcessID) if err != nil { log.Println(err) } return deploymentProcess } ``` -------------------------------- ### Install NGINX on CentOS Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/runbooks/runbook-examples/routine/installing-nginx.md This script installs NGINX on CentOS systems by updating repositories, installing the NGINX package, configuring the firewall, and starting the NGINX service. Choose the appropriate firewall rule for your setup. ```bash # Update repositories sudo yum check-update # Install NGINX sudo yum install nginx -y # Configure firewall # Uncomment out the line that meets your needs sudo firewall-cmd --permanent --zone=public --add-service=http --add-service=https # both ports 80 and 443 # sudo firewall-cmd --permanent --zone=public --add-service=http # port 80 only # sudo firewall-cmd --permanent --zone-public --add-service=https # port 443 only sudo firewall-cmd --reload # Start the service sudo systemctl start nginx ``` -------------------------------- ### Create Instance Command Usage Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/octopus.server.exe-command-line/create-instance.md Lists the available options for the `create-instance` command, including instance name, configuration path, home directory, and server node name. ```bash Usage: octopus.server create-instance [] Where [] is any of: --instance=VALUE Name of the instance to create. If not supplied, creates an instance called OctopusServer. --config=VALUE Path to configuration file to create --home=VALUE [Optional] Path to the home directory - defaults to the same directory as the config file --serverNodeName=VALUE [Optional] Unique Server Node name for a clustered environment - defaults to the machine name Or one of the common options: --help Show detailed help for this command ``` -------------------------------- ### Install and Start Tentacle as a Systemd Service Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/infrastructure/deployment-targets/tentacle/linux/index.mdx Use the Tentacle service command to automatically install and start Tentacle as a systemd service. This is the recommended way to run Tentacle in production. ```bash /opt/octopus/tentacle/Tentacle service --install --start ``` -------------------------------- ### Connect Tenant to Project Example Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-tenant-connect.mdx This example demonstrates how to connect a specific tenant to a project and environment using the Octopus CLI. Ensure the tenant, project, and environment names are accurate. ```bash octopus tenant connect --tenant "Bobs Wood Shop" --project "Deploy web site" --environment "Production" ``` -------------------------------- ### Get Installed VM Extensions Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/infrastructure/deployment-targets/tentacle/windows/azure-virtual-machines/via-the-azure-cli.mdx Retrieves a list of all extensions currently installed on a specified Azure VM. This helps in verifying installations and identifying existing extensions. ```sh $ azure vm extension get --resource-group "" --vm-name" " + Looking up the VM "" data: Publisher Name Version State data: ----------------- -------------------------- ------- -------- data: Microsoft.Compute WinRMCustomScriptExtension 1.4 Creating info: vm extension get command OK ``` -------------------------------- ### Octopus CLI Project Create Examples Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-project-create.mdx Demonstrates basic and configured project creation using the Octopus CLI. Use these examples to quickly create projects with specific settings. ```bash octopus project create ``` ```bash octopus project create --process-vcs ``` ```bash octopus project create --name 'Deploy web app' --lifecycle 'Default Lifecycle' --group 'Default Project Group' ``` -------------------------------- ### Get Installed VM Extensions (ARM Mode) Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/infrastructure/deployment-targets/tentacle/windows/azure-virtual-machines/via-powershell.mdx Retrieves information about a specific extension installed on an Azure VM in ARM mode. ```powershell Get-AzureRmVMExtension -ResourceGroupName "" ` -VMName "" ` -Name "OctopusDeployWindowsTentacle" ``` -------------------------------- ### Get Installed VM Extensions (ASM Mode) Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/infrastructure/deployment-targets/tentacle/windows/azure-virtual-machines/via-powershell.mdx Retrieves a list of all installed extensions on a specified Azure VM in ASM mode. ```powershell $vm = Get-AzureVm -Name "" -servicename "" Get-AzureVMExtension -VM $vm ``` -------------------------------- ### Create Azure Account Example Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-account-azure-create.mdx This is a basic example of how to initiate the creation of an Azure account using the Octopus CLI. Ensure all required flags are provided for a successful creation. ```bash octopus account azure create ``` -------------------------------- ### Convert Project to Config As Code Example Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-project-convert.mdx Example of converting a project named 'Deploy web site' to use Config As Code, specifying the Git repository URL. ```bash octopus project convert --project "Deploy web site" --git-url https://github.com/orgname/reponame ``` -------------------------------- ### Get Installed VM Extensions on a VM Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/infrastructure/deployment-targets/tentacle/windows/azure-virtual-machines/via-the-azure-cli.mdx Fetches details of all extensions currently installed on a specified Azure VM in ASM mode. Provides information on publisher, name, version, and state. ```sh $ azure vm extension get "" info: Executing command vm extension get + Getting virtual machines data: Publisher Extension name ReferenceName Version State data: -------------------- ---------------- -------------------------- ------- ------ data: OctopusDeploy.Ten... OctopusDeploy... OctopusDeployWindowsTen... 2.0 Enable info: vm extension get command OK ``` -------------------------------- ### Get Available Windows Features Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/runbooks/runbook-examples/routine/installing-software-chocolatey.md Run this command in PowerShell to list all available Windows features that can be installed. ```powershell Dism /online /Get-Features ``` -------------------------------- ### Create and Deploy Release with Tenants (C#) Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/scripts/create-and-deploy-release-with-tenants-scripts.include.md This C# snippet demonstrates how to create a release and deploy it to multiple tenants. It fetches necessary resources like projects, channels, and environments, then iterates through packages to set versions before creating the release and subsequent deployments. ```csharp var projectName = "Your Project Name"; var channelName = "Default"; var environmentName = "Dev"; var tenantNames = new string[] { "Customer A Name", "Customer B Name" }; try { // Get the space to work in var space = repository.Spaces.FindByName(spaceName); Console.WriteLine($"Using Space named {space.Name} with id {space.Id}"); // Create space specific repository var repositoryForSpace = repository.ForSpace(space); // Get project by name var project = repositoryForSpace.Projects.FindByName(projectName); Console.WriteLine($"Using Project named {project.Name} with id {project.Id}"); // Get channel by name var channel = repositoryForSpace.Channels.FindByName(project, channelName); Console.WriteLine($"Using Channel named {channel.Name} with id {channel.Id}"); // Get environment by name var environment = repositoryForSpace.Environments.FindByName(environmentName); Console.WriteLine($"Using Environment named {environment.Name} with id {environment.Id}"); // Get the deployment process template Console.WriteLine("Fetching deployment process template"); var process = repositoryForSpace.DeploymentProcesses.Get(project.DeploymentProcessId); var template = repositoryForSpace.DeploymentProcesses.GetTemplate(process, channel); var release = new Octopus.Client.Model.ReleaseResource { ChannelId = channel.Id, ProjectId = project.Id, Version = template.NextVersionIncrement }; // Set the package version to the latest for each package // If you have channel rules that dictate what versions can be used // you'll need to account for that by overriding the selected package version Console.WriteLine("Getting action package versions"); foreach (var package in template.Packages) { var feed = repositoryForSpace.Feeds.Get(package.FeedId); var latestPackage = repositoryForSpace.Feeds.GetVersions(feed, new[] { package.PackageId }).FirstOrDefault(); var selectedPackage = new Octopus.Client.Model.SelectedPackage { ActionName = package.ActionName, Version = latestPackage.Version }; Console.WriteLine($"Using version {latestPackage.Version} for step {package.ActionName} package {package.PackageId}"); release.SelectedPackages.Add(selectedPackage); } // # Create release release = repositoryForSpace.Releases.Create(release, false); // pass in $true if you want to ignore channel rules var tenants = repositoryForSpace.Tenants.FindByNames(tenantNames); foreach (var tenant in tenants) { // # Create deployment var deployment = new Octopus.Client.Model.DeploymentResource { ReleaseId = release.Id, EnvironmentId = environment.Id, TenantId = tenant.Id }; Console.WriteLine($"Creating deployment for release {release.Version} of project {projectName} to environment {environmentName} and tenant {tenant.Name}"); deployment = repositoryForSpace.Deployments.Create(deployment); } } catch (Exception ex) { Console.WriteLine(ex.Message); } ``` -------------------------------- ### Run Local Preview Source: https://github.com/octopusdeploy/docs/blob/main/README.md Commands to install dependencies, run a local preview of the site, and generate a static copy. ```bash pnpm install pnpm dev pnpm build pnpm preview ``` -------------------------------- ### List Supported Commands with Auto-completion Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/octopus-cli/complete.md Use this command to get auto-completion suggestions for commands starting with 'list'. ```bash octo complete list ``` -------------------------------- ### Package a .NET Framework Web Application Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/packaging-applications/create-packages/octopus-cli.md This example uses msbuild parameters to prepare and publish a .NET Framework web application, followed by creating a ZIP package. Note that Octopack is often recommended for these cases. ```bash msbuild ./OctoWeb.csproj /p:DeployDefaultTarget=WebPublish /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:SkipInvalidConfigurations=true /p:publishUrl=dist octopus package zip create --id="OctoWeb" --version="1.0.0-alpha0001" --base-path="./dist" ``` -------------------------------- ### Auto-completion Results for 'list' Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/octopus-cli/complete.md Example output showing the supported commands that start with 'list' when using the auto-completion feature. ```bash list-deployments list-environments list-latestdeployments list-machines list-projects list-releases list-tenants list-workerpools list-workers ``` -------------------------------- ### Package Application from a Folder Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/packaging-applications/create-packages/octopus-cli.md This example shows how to package an application when build outputs are consolidated into a specific folder, such as after running an npm script. ```bash npm run build octopus package zip create --id="OctoWeb" --version="1.0.0" --base-path="./dist" ``` -------------------------------- ### Disable a Project with Octopus CLI Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-project-disable.mdx Example of how to disable a project using the Octopus CLI. Ensure you have the CLI installed and configured. ```bash octopus project disable ``` -------------------------------- ### Install Tomcat on Ubuntu Runbook Script Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/runbooks/runbook-examples/routine/installing-tomcat.md This Bash script installs Tomcat on an Ubuntu machine. It checks if Tomcat is already installed, installs Java and jq, downloads the latest Tomcat version, creates a Tomcat user and group, sets up a systemd service, configures a management user, starts the Tomcat service, and opens port 8080 in the firewall. It uses Octopus Deploy variables for user and password configuration. ```bash #!/bin/bash TOMCAT_INSTALL_STARTUP=/opt/tomcat/latest/bin/startup.sh if [[ -f $TOMCAT_INSTALL_STARTUP ]]; then echo "Tomcat already installed." else TOMCAT_USER=#{Runbook.InstallTomcat.Tomcat.User} TOMCAT_GROUP=#{Runbook.InstallTomcat.Tomcat.Group} TOMCAT_ADMIN_USER=#{Runbook.InstallTomcat.Tomcat.AdminUser} TOMCAT_ADMIN_PASSWORD=#{Runbook.InstallTomcat.Tomcat.AdminPassword} sudo apt-get update echo "Installing Java..." sudo apt install default-jdk -y echo "Installing jq..." sudo apt install jq -y LATEST_TOMCAT=$(curl -s 'https://api.github.com/repos/apache/tomcat/tags' | jq -r .[].name | grep -v '-' | head -1) echo "Creating tomcat group ..." sudo groupadd $TOMCAT_GROUP -r if [[ ! -d /opt/tomcat ]]; then echo "Making tomcat folder" sudo mkdir /opt/tomcat fi echo "Creating tomcat Linux user ..." sudo useradd -r -m -d /opt/tomcat -s /bin/false -g $TOMCAT_GROUP $TOMCAT_USER echo "Downloading Tomcat version $LATEST_TOMCAT..." wget http://www.apache.org/dist/tomcat/tomcat-9/v$LATEST_TOMCAT/bin/apache-tomcat-$LATEST_TOMCAT.tar.gz -P /tmp echo "Extracting Tomcat..." sudo tar xf /tmp/apache-tomcat-$LATEST_TOMCAT.tar.gz -C /opt/tomcat echo "Creating symbolic link..." sudo ln -s /opt/tomcat/apache-tomcat-$LATEST_TOMCAT /opt/tomcat/latest sudo chown -RH $TOMCAT_USER: /opt/tomcat/latest sudo sh -c 'chmod +x /opt/tomcat/latest/bin/*.sh' echo "Creating Tomcat service file..." cat >> tomcat.service < /opt/tomcat/latest/conf/tomcat-users.xml < EOF echo "Starting Tomcat..." sudo systemctl daemon-reload sudo systemctl start tomcat sudo systemctl enable tomcat echo "Altering firewall rules..." sudo ufw allow 8080/tcp fi echo "Process complete" ``` -------------------------------- ### Create Tenant with Go Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/scripts/create-a-tenant-scripts.include.md This Go program demonstrates how to create a new tenant using the Octopus Deploy SDK. It includes functions to authenticate, retrieve space, project, and environment details, and then add the new tenant. ```go package main import ( "fmt" "log" "net/url" "github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy" ) func main() { apiURL, err := url.Parse("https://your-octopus-url") if err != nil { log.Println(err) } APIKey := "API-YOUR-KEY" spaceName := "Default" tenantName := "MyTenant" environmentNames := []string{"Development", "Test"} projectNames := []string{"MyProject"} tenantTags := []string{"TagSet/Tag"} projectEnvironments := make(map[string][]string) // Get reference to space space := GetSpace(apiURL, APIKey, spaceName) // Loop through environments for i := 0; i < len(projectNames); i++ { project := GetProject(apiURL, APIKey, space, projectNames[i]) environmentIds := []string{} for j := 0; j < len(environmentNames); j++ { environment := GetEnvironment(apiURL, APIKey, space, environmentNames[j]) environmentIds = append(environmentIds, environment.ID) } projectEnvironments[project.ID] = environmentIds } // Create new tenant tenant := octopusdeploy.NewTenant(tenantName) tenant.SpaceID = space.ID tenant.ProjectEnvironments = projectEnvironments tenant.TenantTags = tenantTags client := octopusAuth(apiURL, APIKey, space.ID) client.Tenants.Add(tenant) } func octopusAuth(octopusURL *url.URL, APIKey, space string) *octopusdeploy.Client { client, err := octopusdeploy.NewClient(nil, octopusURL, APIKey, space) if err != nil { log.Println(err) } return client } func GetSpace(octopusURL *url.URL, APIKey string, spaceName string) *octopusdeploy.Space { client := octopusAuth(octopusURL, APIKey, "") spaceQuery := octopusdeploy.SpacesQuery{ Name: spaceName, } // Get specific space object spaces, err := client.Spaces.Get(spaceQuery) if err != nil { log.Println(err) } for _, space := range spaces.Items { if space.Name == spaceName { return space } } return nil } func GetProject(octopusURL *url.URL, APIKey string, space *octopusdeploy.Space, projectName string) *octopusdeploy.Project { // Create client client := octopusAuth(octopusURL, APIKey, space.ID) projectsQuery := octopusdeploy.ProjectsQuery { Name: projectName, } // Get specific project object projects, err := client.Projects.Get(projectsQuery) if err != nil { log.Println(err) } for _, project := range projects.Items { if project.Name == projectName { return project } } return nil } func GetEnvironment(octopusURL *url.URL, APIKey string, space *octopusdeploy.Space, environmentName string) *octopusdeploy.Environment { // Get client for space client := octopusAuth(octopusURL, APIKey, space.ID) // Get environment environmentsQuery := octopusdeploy.EnvironmentsQuery { Name: environmentName, } environments, err := client.Environments.Get(environmentsQuery) if err != nil { log.Println(err) } // Loop through results for _, environment := range environments.Items { if environment.Name == environmentName { return environment } } return nil } ``` -------------------------------- ### Install and Configure Polling Worker on Fedora/CentOS/RedHat Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/infrastructure/quickstart-fedora.include.md Installs the Tentacle package, creates an instance, configures it for polling communication, and registers it as a worker. This setup is for worker nodes that initiate communication with the Octopus Server. Ensure the server URL, API key, and other parameters are set correctly. ```bash serverUrl="https://my-octopus" # The url of your Octous server serverCommsPort=10943 # The communication port the Octopus Server is listening on (10943 by default) apiKey="" # An Octopus Server api key with permission to add machines spaceName="Default" # The name of the space to register the Tentacle in name=$HOSTNAME # The name of the Tentacle at is will appear in the Octopus portal workerPool="Default Worker Pool" # The worker pool to register the Tentacle in ``` -------------------------------- ### Create Project with Custom Deployment Step Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-ai/assistant/project-creation.md This prompt demonstrates how to create a project, add a custom bash script step to the deployment process, specify its position, and define conditions for its execution, such as excluding it from a specific environment. ```text Create an AWS Lambda project called "Gift Card" in the project group "Retail". Create an additional step in the deployment process called "Run smoke tests". The step should be a bash script and should test a HTTP endpoint returns a 200 status code. Add the step after the Deploy a Lambda step in the deployment process. Ensure the new step doesn't run in the Security environment. ``` -------------------------------- ### Create a Dynamic Worker Pool Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-worker-pool-dynamic-create.mdx This is a basic example of creating a dynamic worker pool using the Octopus CLI. Ensure you have the CLI installed and configured. ```bash octopus worker-pool dynamic create ``` -------------------------------- ### Octopus CLI Release Deploy Examples Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-release-deploy.mdx Provides examples of how to deploy releases using the Octopus CLI with various flag combinations. These demonstrate interactive deployment, specifying project, version, and environment, as well as advanced options like tenant tags, skipping steps, and forcing package downloads. ```bash octopus release deploy # fully interactive ``` ```bash octopus release deploy --project MyProject --version 1.0 --environment Dev ``` ```bash octopus release deploy --project MyProject --version 1.0 --tenant-tag Regions/East --tenant-tag Regions/South ``` ```bash octopus release deploy -p MyProject --version 1.0 -e Dev --skip InstallStep --variable VarName:VarValue ``` ```bash octopus release deploy -p MyProject --version 1.0 -e Dev --force-package-download --guided-failure true -f basic ``` -------------------------------- ### Configure All Paths to Network Share Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/octopus.server.exe-command-line/path.md This example configures all paths (artifacts, task logs, packages, imports, and telemetry) to a network share using the `--clusterShared` option. ```bash octopus.server path --clusterShared \\OctoShared\OctopusData ``` ```bash octopus.server path --artifacts Artifacts ``` ```bash octopus.server path --taskLogs TaskLogs ``` ```bash octopus.server path --nugetRepository Packages ``` ```bash octopus.server path --imports Imports ``` ```bash octopus.server path --eventExports EventExports ``` ```bash octopus.server path --telemetry Telemetry ``` -------------------------------- ### Create an Ephemeral Environment with Octopus CLI Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-ephemeral-environment-create.mdx A simple example of how to execute the command to create an ephemeral environment. Ensure you have the Octopus CLI installed and configured. ```bash octopus ephemeral-environment create ``` -------------------------------- ### Delete a Space using C# Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/scripts/delete-a-space-scripts.include.md A C# example demonstrating how to delete a space using the Octopus.Client library. Ensure the System.Security.Permissions NuGet package is installed for .NET Core. ```csharp // If using .net Core, be sure to add the NuGet package of System.Security.Permissions #r "nuget: Octopus.Client" using Octopus.Client; using Octopus.Client.Model; var OctopusURL = "https://your-octopus-url"; var OctopusAPIKey = "API-YOUR-KEY"; var endpoint = new OctopusServerEndpoint(OctopusURL, OctopusAPIKey); var repository = new OctopusRepository(endpoint); var spaceName = "New Space"; try { Console.WriteLine($"Getting space '{spaceName}'."); var space = repository.Spaces.FindByName(spaceName); if (space == null) { Console.WriteLine($"Could not find space '{spaceName}'."); return; } Console.WriteLine("Stopping task queue."); space.TaskQueueStopped = true; repository.Spaces.Modify(space); Console.WriteLine("Deleting space"); repository.Spaces.Delete(space); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } ``` -------------------------------- ### Install .NET SDK and Runtime Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/deployments/nginx/configure-target-machine.md Update package lists and install the ASP.NET Core runtime version 2.1. Ensure apt-transport-https is installed first. ```bash sudo apt-get install apt-transport-https sudo apt-get update sudo apt-get install aspnetcore-runtime-2.1 ``` -------------------------------- ### Octopus CLI Create Token Account Example Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-account-token-create.mdx This example demonstrates the basic command to create a token account. Ensure you have the necessary permissions and have configured your CLI environment. ```bash octopus account token create ``` -------------------------------- ### Example: View Build Information Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-build-information-view.mdx Demonstrates how to view a specific build information by its ID using the Octopus CLI. ```bash octopus build-information view BuildInformation-1 ``` ```bash octopus build-info view BuildInformation-1 ``` -------------------------------- ### List and View Octopus Spaces Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-space.mdx Examples of how to list all available spaces and view a specific space by its ID using the Octopus CLI. Ensure you have the CLI installed and authenticated. ```bash octopus space list ``` ```bash octopus space view Spaces-302 ``` -------------------------------- ### Get Octopus Events by Date (PowerShell) Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/scripts/find-events-by-date-scripts.include.md Retrieves events from Octopus Deploy within a specified date range using PowerShell. Ensure you have the Octopus.Client module installed. ```powershell $octopusURL = "https://your-octopus-url" $octopusAPIKey = "API-YOUR-KEY" $spaceName = "default" $eventDate = "8/1/2021" $endpoint = New-Object Octopus.Client.OctopusServerEndpoint $octopusURL, $octopusAPIKey $repository = New-Object Octopus.Client.OctopusRepository $endpoint $client = New-Object Octopus.Client.OctopusClient $endpoint try { # Get space $space = $repository.Spaces.FindByName($spaceName) $repositoryForSpace = $client.ForSpace($space) # Get events $events = $repositoryForSpace.Events.List(0, $null, $eventDate) $returnedItems = $events $skip = $returnedItems.Items.Count while ($returnedItems.Items.Count -eq $returnedItems.ItemsPerPage) { $returnedItems = $repositoryForSpace.Events.List($skip, $null, $eventDate) $skip += $returnedItems.Items.Count $events.Items.AddRange($returnedItems.Items) } foreach ($item in $events.Items) { $item } } catch { Write-Host $_.Exception.Message } ``` -------------------------------- ### Create Octopus Release with Basic Parameters Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-release-create.mdx Basic example of creating a release specifying project, channel, and version. Demonstrates the use of both long and short flag names. ```bash octopus release create --project MyProject --channel Beta --version 1.2.3 ``` ```bash octopus release create -p MyProject -c Beta -v 1.2.3 ``` -------------------------------- ### Create a runbook snapshot with package version and no prompt Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/cli/octopus-runbook-snapshot-create.mdx This example demonstrates creating a snapshot for a specific runbook, specifying a package version, and disabling interactive prompts. Use the shorthand flags for project (-p) and runbook (-r). ```bash octopus runbook snapshot create -p MyProject -r "Restart App" --package "azure-cli:1.2.3" --no-prompt ``` -------------------------------- ### Configure BLOB Storage for Windows Host Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/best-practices/self-hosted-octopus/high-availability.mdx Use this command to configure BLOB storage for a Windows host installation of Octopus Deploy. This is a required step after the initial setup wizard. ```powershell Octopus.Server.exe path --clusterShared \\OctoShared\OctopusData ``` -------------------------------- ### Create Channel using C# Source: https://github.com/octopusdeploy/docs/blob/main/src/shared-content/scripts/create-channel-scripts.include.md A C# example demonstrating how to create a channel in Octopus Deploy using the Octopus.Client library. Ensure the System.Security.Permissions NuGet package is installed for .NET Core. ```csharp // If using .net Core, be sure to add the NuGet package of System.Security.Permissions #r "nuget: Octopus.Client" using Octopus.Client; using Octopus.Client.Model; var octopusURL = "https://your-octopus-url"; var octopusAPIKey = "API-YOUR-KEY"; var spaceName = "Default"; var projectName = "MyProject"; var channelName = "NewChannel"; // Create repository object var endpoint = new OctopusServerEndpoint(octopusURL, octopusAPIKey); var repository = new OctopusRepository(endpoint); var client = new OctopusClient(endpoint); // Get space var space = repository.Spaces.FindByName(spaceName); var spaceRepository = client.ForSpace(space); // Get project var project = spaceRepository.Projects.FindByName(projectName); // Create channel object var channel = new Octopus.Client.Model.ChannelResource(); channel.Name = channelName; channel.ProjectId = project.Id; channel.SpaceId = space.Id; spaceRepository.Channels.Create(channel); ``` -------------------------------- ### Configure Individual Component Paths Source: https://github.com/octopusdeploy/docs/blob/main/src/pages/docs/octopus-rest-api/octopus.server.exe-command-line/path.md This example configures the paths for different components individually, specifying unique network locations for each. ```bash octopus.server path --artifacts \\Octoshared\OctopusData\Artifacts ``` ```bash octopus.server path --taskLogs \\Octoshared\OctopusData\TaskLogs ``` ```bash octopus.server path --nugetRepository \\Octoshared\OctopusData\Packages ``` ```bash octopus.server path --imports \\Octoshared\OctopusData\Imports ``` ```bash octopus.server path --eventExports \\Octoshared\OctopusData\EventExports ``` ```bash octopus.server path --telemetry \\Octoshared\OctopusData\Telemetry ```