rolsped
rolsped

Reputation: 13

Build Pipeline fails at "Initialize Job" step

I have set up a build pipeline, that builds a solution(windows service), publishes it on a windows server and starts up the service. It runs flawless for the first time.

After that, when I trigger the pipeline, it fails at the "Initialize Job" step and reports that it can't remove some of the files in the Debug folder.

While I know why it can't delete these files(the service is running), I can't figure out a way to stop the service beforehand. I tried running a powershell script as first task like following with script so that it can delete my previous build

if (Get-Service "MyService" -ErrorAction SilentlyContinue) {

    net stop MyService
    sc.exe delete MyService

}

But it fails even before executing any task from the pipeline.

What's the best way to go about it?

Upvotes: 0

Views: 1676

Answers (1)

JukkaK
JukkaK

Reputation: 1175

I've used these Windows Service Release Tasks in on-prem servers:

https://marketplace.visualstudio.com/items?itemName=jabbera.windows-service-release-tasks

Looking at the attached image, I think might be trying to put stuff that's not supposed to be there in the build pipeline. Instead of trying to install services as a part of the build pipeline (or build stage of multi-stage pipeline), separate deployment tasks to release pipeline (or release stages of multi-stage pipeline). You are now essentially running operations that try to create services within the build agent and you want to run them in the server you are copying the build results into.

Run the release pipeline with deployment group agents so the release is executed at the server you are deploying to, or if that's not possible, run the release pipeline with hosted agents/build server agents, but use WinRM to run the tasks against target server.

Upvotes: 1

Related Questions