We are planning to migrate our existing release process to Octopus Deploy. To achieve this, we create a new build definition in TFS and pushed the build to octopus deploy successfully.
In the next step, we created a series of Deployment Steps in the newly created Octopus Project.
The steps will include the below deployment proces:
Stop the windows service - Working fine
Delete windows service - Working fine
Create and Start the windows service : #we encounter the below issue:
we used the below powershell script to create and start the windows service from Octopus Server:
Does this Powershell script work if run directly on the target machine within Powershell?
Also, Octopus does have a built-in step for deploying and creating Windows services, have you given that step a try or is it missing some functionality that you require?
Finally, when attaching scripts, if you enclose them in blocks of three backticks ``` it should format the script more neatly
e.g.
[quote=“paul.calvert, post:2, topic:24229”]
Does this Powershell script work if run directly on the target machine within Powershell?
Sriram : The same code works fine for other windows service. I can share the screen…
Also, Octopus does have a built-in step for deploying and creating Windows services, have you given that step a try or is it missing some functionality that you require?
Sriram: I tried the above step as well. Can you give some steps on how to setup your above built-in step?
To configure the built-in ‘Deploy a Windows Service’ step, you would just need to pass in the same information you are using for your script. Typically, I would use variables for these values within the process step, and then create and define them within the Project Variables section. This way it provides flexibility for having different service names or paths for different environments or roles without having to have multiple process steps.
e.g.
You can also configure what user the service should run under, and again use variables to alter this based on the environment, and a sensitive variable for the user password.
Are you able to expand on what issues you are experiencing, please?
If you are seeing errors during deployment, perhaps it would be useful to attach the deployment log for me to take a look at?
As long as the path is within a variable you shouldn’t have to escape the space. However, calling the item directly from the array does look like it causes the wrong value to be inserted but it didn’t error for me.
I put together two test scripts to create services using your values, and both of these resulted in the service being created with the correct path and arguments.