running process with gitlab ci - windows

I have a gitlab runner installed on one of my test servers.
I want to build and deploy my app on every commit.
The server is a windows server and the app is a .net core 1.1 app.
my build script works fine but eventually it runs dotnet MyApp.dll which obviously makes the pipeline stop wait until it finishes (but, of course, my app won't finish, I want it to run..)
I tried running start dotnet MyApp.dll but that still doesn't work as gitlab's runner won't stop running until all of it's child processes exit.
I am certain I'm using gitlab's CI in a non idiomatic way but fail to understand how to deploy locally correctly.
Any suggestions?

Windows doesn't offer any easy way to disown a process and you probably don't want to task yourself with stopping the process on your next deploy. What you should do is use SRVANY.EXE to create service out of your application and then use the Gitlab CI to stop the service, replace the files and run it again. It's been a while since I used Windows so I'm sorry but I can't provide the exact commands to run.

Related

How to start an application on Windows after a Jenkins build

I am want to start a (Spring Boot) application on a Windows server after it was built by Maven, which was started by Jenkins.
I am able to build in Jenkins using mvn spring-boot:run, which automatically starts the application, but this results in a Jenkins build process that never finishes. I want the application to start and to continue running while the Jenkins build finishes.
Also, when I need to stop and restart the application, I need to
stop/kill the Jenkins build process
look up the application's Java process that was started via the Windows Task Manager and kill that as well, since the application keeps running in a separate process.
There must be a better way to do that.
If you have Jenkins build pipeline, it is easy to build the application and run the application. You can follow this link to get an idea. Although this link is unix system, you can modify to do it for Windows.
https://vindytechblog.wordpress.com/2017/03/04/jenkins-configurations-to-build-and-deploy-wso2-carbon-application/
Also, you can mention the command in the last pipeline about what to do after building the application. Besides, you have to first stop already running the spring boot application instance.
You can also refer below the link about the pipeline script.
https://www.baeldung.com/jenkins-pipelines

Using Jenkins pipeline to build an exising job hangs at "Scheduling Project"

I have multiple existing projects which build fine. They run MSBUILD on a windows agent running the windows service.
I wanted to create a single project that builds them all in a particular order and collects the artifacts from all of them. I decided to try creating a pipeline. When I run it it gets to the first build statement and then just hangs there, no error it just says "Scheduling Project:.." and the little wheel spins forever. The job its trying to start normally finishes in a few seconds.
stage('job1'){
node('windows'){
build job:'job1', quietPeriod: 0, wait: true
}
}
I have to kill the build manually, it never starts the job.
Ok I managed to rearrange things so that the pipeline runs on the master and the individual jobs and artifact copies run one at a time on the slave, its working now.

Using MongoDB (in a container?) in Visual Studio Team Services pipelines

I have a node.js server that communicates with a MongoDB database. As part of the continuous-integration process I'd like to spin up a MongoDB database and run my tests against the server + DB.
With bitbucket pipelines I can spin up a container that has both node.js and MongoDB. I then run my tests against this setup.
What would be the best way to achieve this with Visual Studio Team Services? Some options that come to mind:
1) Hosted pipelines seem easiest but they don't have MongoDB on them. I could use Tool Installers, but there's no mention of a MongoDB installer, and in fact I don't see any tool installer in my list of available tasks. Also, it is mentioned that there is no admin access to the hosted pipeline machines and I believe MongoDB requires admin access. Lastly, downloading and installing Mongo takes quite a bit of time.
2) Set up my own private pipeline - i.e. a VM with Node + Mongo, and install the pipeline agent on it. Do I have to spin up a dedicate Azure instance for this? Will this instance be torn down and set up again on each test run, or will it remain up between test runs (meaning I have to take extra care to clean it up)?
3) Magically use a container in the pipeline through an option that I haven't yet discovered...?
I'd really like to use a container to run my tests because then I can use the same container locally during the development process, rather than having to maintain multiple environments. Can this be done?
So as it turns out, VSTS now has Docker support in its pipeline (when I wrote my question it was in beta and I didn't find it for whatever reason). It can be found at https://marketplace.visualstudio.com/items?itemName=ms-vscs-rm.docker.
This command allows you to spin up a container of your choice and run a single command on it. If this command is to be synchronously run as part of the pipeline, then Run in Background needs to be unchecked (this will be the case for regular build commands, I guess). I ended up pushing a build script into my git repository and running it on a container.
And re. my question in (2) above - machines in private pipelines aren't cleaned up between pipeline runs.

Packer - Parallel Builds - Stop All Builds if One Fails

I'm using Packer to create AWS AMIs for deployment. I build a couple in Parallel for different types of AMIs (Application server, Worker server), and provision them using Ansible.
However, if one of the build processes fail, I want to halt the entire build process for all parallel builds. Is there a way to accomplish this with packer?
No.
(Unless you do some strange script that runs last in all builds and wait for all other or times out. But you better do a cleanup script that checks the result of the Packer build and deregister AMI's if one of build failed.)

Run failed tests from TFS post build event

We are using TFS/VS 2010 to run Selenium tests which are scheduled in the TFS controller. After the build and tests are finished I would like to run the failed tests from that build.
Currently I am doing this by using a Windows Scheduled Task and executing a batch file which calls a powershell script which gets the latest build version (and failed tests) and then executes them (using mstest) and finally publishes the results back to build.
I just want this to happen without a windows scheduled task, it is too fickle. I believe I need to edit ProcessTemplate.xaml and add an event (InvokeProcess) to achieve this, I just can't find much on it.
Thanks in advance!

Resources