How to do it...

  1. Log in to your Octopus Deploy instance and navigate to Projects | All.
  2. On the Projects page, click on Add project and create a project with the name Dynamics 365.
  3. Click on the Save button.
  4. In the Dynamics 365 project page, click on Process on the left-hand side navigation and then click on Add step.
  5. Hover over Run a Script and click on Add step.
  6. On the Step details page, add the following details:
    • Step name: Deploy Dynamics 365 Solution
    • Run on: Octopus Sever
    • Script source: Script file inside a package
    • Package feed: Octopus Server (built-in)
    • Package Id: Packt
    • Script file name: ImportDynamics365Solution.ps1
    • Script parameters: -username #{username} -password #{password} -instance #{instance} -organisation #{organization}
    • Click on Save
  1. Back in your Dynamics 365 project, click on Variables from the left-hand side navigation, create the following variables with their corresponding values and set the scope to Development:
    • Instance
    • Organization
    • Username
  2. Create a password variable, click on the value field, click on Show editor, and enter the following details:
  • Choose a variable type: Sensitive
  • In the Value pane, enter your password
  • Click on Apply
  1. Back in your filesystem, create a PowerShell script called ImportDynamics365Solution.ps1 with the following code:
param (    
[string]$username,
[string]$password,
[string]$instance,
[string]$organisation
)
Import-Module Microsoft.Xrm.Data.Powershell

$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ($username, $securePassword)

$connection = Get-CrmConnection -Credential $credentials -ServerUrl $instance -OrganizationName $organisation

Import-CrmSolution -SolutionFilePath Packt_managed.zip -conn $connection -PublishChanges
  1. Package ImportDynamics365Solution.ps1 and Packt_managed.zip into one ZIP file called Packt.0.0.0.1.zip.
  2. Upload your artifact (newly created ZIP file) to Octopus Deploy using the octo command line:
octo push -server=<octopus server URL> --package=Packt.0.0.0.1.zip -apiKey=<api key> 
  1. Back in Octopus, click on your Dynamics 365 project and then click on Create release.
  2. Select the artifact version you just uploaded (version 0.0.0.1) from the list of packages and click on Save.
  3. On the Release page, click on Deploy to Development.
  4. On the Development deployment page, click on Deploy now and monitor the progress.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset