CI/CD pipeline to deploy code on local system for staging and production enviroment
Asked by manojkumar:

I want to create CI/CD for the .net core application with two environments staging and production. At the moment both the staging and production environments are on my system and want to save published code on the local system directory. What configuration should I need to setup? Is it possible without a runner process?


Answers:
author: Patrik S
body: Hello [@manojkumar](/t5/user/viewprofilepage/user-id/5360408) and welcome to the Community!

If you are looking to deploy your code to a local server that is only accessible from your private network, then self-hosted runners would be the way to go, as they would run in your own infrastructure and have access to the private network.

However, if you want to use the cloud runners, where the build will be executed in Atlassian infrastructure, then the server you are going to deploy the code to must be accessible from the internet and the [Valid IP addresses for pipelines build environments](https://support.atlassian.com/bitbucket-cloud/docs/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall/#Valid-IP-addresses-for-Bitbucket-Pipelines-build-environments) must be allowed to connect to your server in case it's behind a firewall.

You can find more details on the differences between cloud and self-hosted runners in the following article:

* [Bitbucket runners comparison](https://confluence.atlassian.com/bbkb/bitbucket-runners-comparison-1384125495.html)

Thank you, [@manojkumar](/t5/user/viewprofilepage/user-id/5360408) !

Patrik S

comments: author: manojkumar
body: Hi Patrik  

Thanks for the information.  

I have successfully set up the self-hosted runners and published code save in my local directory. But now self-hosted runners service status is showing offline after some time and it's not starting again automatically. Are there any configuration settings that will be used to set the self-hosted runners service online before publishing the code?


author: Patrik S
body: Hello [@manojkumar](/t5/user/viewprofilepage/user-id/5360408) ,

The runner will only be available while the runner agent is running in the host machine.

It's essential that the runner agent remains online and running for Bitbucket Pipelines to assign job execution to it. If you stop the runner agent or exit the process, it will become unavailable/offline in the UI and not able to run your jobs.

That being said, depending on the type of runner you are using, there are a few strategies to configure runner auto-start when the host is booted. I'm sharing below the different articles that explain this process for each type of runner:

* Linux Docker runner - use the [docker container restarting policies](https://community.atlassian.com/t5/Bitbucket-questions/Bitbucket-self-hosted-runner-autostart/qaq-p/1868071)
* Windows runner - [Set up runners for Windows as a windows service](https://confluence.atlassian.com/bbkb/bitbucket-cloud-pipelines-set-up-runners-for-windows-as-a-windows-service-1223821219.html)
* Linux Shell runner - [Setup Linux Shell runners as a service](https://confluence.atlassian.com/bbkb/setup-linux-shell-runners-as-a-service-1316519995.html)

Hope that information helps! Let us know in case you have any questions.

Thank you, [@manojkumar](/t5/user/viewprofilepage/user-id/5360408) !

Patrik S


Tags: bitbucket-cloud

cloud