Can capistrano v3 specify HOSTS in command line like v2 does? - capistrano

In Capistrano v2, I can run deploy on the server specified in the command-line.
cap staging HOSTS="host1,host2" deploy
How can I do the same thing in the Capistrano v3?
example scenario
I have to scale my app, but I don't want to deploy all of my app servers. So I just want to run deploy on the new one.

Not sure if you found this or not but the documentation says you can just list it in the command line like this:
cap --hosts=server1,server2 production deploy
See documentation here:
Host Filtering Docs
See code here:
Code Filtering Link
Looking at the code, it appears to be able to accepts HOSTS also.
See test confirming this:
Test Confirming Both Options

Related

Why my Azure functions are not visible in the function list after my deployment from GitHub/Kudu?

I'm trying to deploy my first HTTP trigger Function App to Azure.
It was created with the Azure Function extension in VS Code with TypeScript template.
I use my GitRepo as a source and the Kudu build App Service.
My functions are working well locally. I can see them in VS Code > Azure tab, Local Project > Functions.
I have no error on the deployment itself but I cannot see my two functions in the Azure Functions list.
In the kudu UI, I see that all my files are correctly deployed :
Kudu screenshoot
My settings are :
settings
Where can I find some logs on what went wrong? Any idea of other things to check?
Any help will be appreciated.
I could use Zip deploy (https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push) as an alternative way to deploy this (I haven't tried it yet). I would like to know what's wrong with my current setup.
Not sure if the problem is that you configure the wrong runtime.
Here is the steps I did:
Create a Function app project with an http-trigger function based on TypeScript in VS Code:
Upload the project to GitHub.
Using deployment center to configure deploy from Git on portal.
After deploy, check in Functions page:
By the way, you could deploy from VS Code directly:

How to run a code analysis locally from the command line using a quality profile on the SonarQube server?

On my SonarQube server I have 2 quality profiles (1 for C# and 1 for JS).
How to run a code analysis from the command line locally using them (retain them on server, without using tools like SonaLint) or using a gulp task?
take a look at the documentation of sonarqube for analyzing source code ( current link https://docs.sonarqube.org/latest/analysis/overview/) - there you find a lot of useful scanners for different environments and languages.
You just need to configure them properly, but this is also something you can find within the docs of sonarqube.
Use the command line scanner. It will run an analysis locally from your command line.
Make sure, that you set sonar.host.url in sonar-project.properties, so that the correct quality profiles will be taken into account.

Visual Studio Online / Azure stopping and starting web applications using Powershell

I'm using Visual Studio Online's build tools to deploy web applications from a single solution. I've occasionally been running into file locking issues.
Error: Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.dll' on the destination because it is locked by an external process.
After some Googling, I believe the "fix" is to stop the web applications before deployment on Azure and start it back up after. Sounds legit.
However, there does not seem to be a straight forward way to do this directly on VSO's build definitions. I've created an "Azure Powershell" build task, but it wants a PS1 file from the repository. It doesn't seem to let me just run Azure Powershell commands (e.g. Stop-AzureWebsite) from here. My team has created a work-around where we have a "run.ps1" that just executes the command you pass as a parameter, but none of us are satisfied by that.
What are we missing? There has got to be an easier way to do this without having a PS1 script checked into source control.
I solved this by installing Azure App Services - Start and Stop extension from Visual Studio Marketplace.
When installed, it will allow you to wrap the Deploy Website to Azure task in your Release definition with Azure AppServices Stop and Azure AppServices Start tasks, effectively eliminating the lock issues.
Check if you are using "/" on the "Web Deploy Package" path for folder separators instead of "\".
i.e. change
$(System.DefaultWorkingDirectory)/My Project/drop/MyFolder/MyFile.zip
for
$(System.DefaultWorkingDirectory)\My Project\drop\MyFolder\MyFile.zip
I noticed that was the only difference between the one I was getting the error and the others (the Restart step I added was not helping). Once I modified the path, I got it working.
Sounds crappy, but fixed my issue.
Did you use the Build Deployment Template that sets the correct msbuild parameters for you for your package? You can see how here. I would create a build using that template and see if you have the same issues. If so ping me on Twitter #DonovanBrown and I will see if I can figure what is going on.
As a rule it is good practice to have any scripts or commands required to deploy your software to be checked into source control as part of your build. They can then be easily run repeatedly with little configuration at the build level. This provides consistency and transparency.
Even better is to have deployment scripts output as part of the build and use a Release Management tool to control the actual deployment.
Regardless having configuration as code is a mantra that all Dev and Ops teams should live by.

Script error while using deploy.ps1 to deploy virtocommerce project

I'm using the official virtocommerce azure deploy script under folder "virtocommerce\src\Extensions\Setup\VirtoCommerce.PowerShell" to deploy virtocommerce(with azure tool v2.4), i encounted some problems while running "deploy.ps1" script in windows azure powershell
In "azure-db.ps1", there's lot of syntax like "Get-Date –f" , the dash character is wrong ,"–" must be "-", otherwise you will get error.
In "azure-deploy.ps1", there's a function "build-search" which use cspack.exe to create "ElasticSearch.cspkg",that's correct, but for other packages such as "CommerceSite.cspkg" and "AzureScheduler.cspkg", i did not found any functions to create those packages, this will lead to an error says "CommerceSite.cspkg" can not be found.
Does anybody has the same problems?
Turn out that there's some problem inside code:
"deploy.ps1" script is using deploy-tfs.ps1 , and use parameter "$build".
parameter "$build" has been reset to 'False' in "deploy-tfs.ps1"
"azure-deploy.ps1" using "$build" to decide if it's need to build the azure package, and this parameter is always 'False', so the azure package will never be creat.
The script is designed to run on azure sdk 2.4, not 2.5. The script is used to deploy daily both demo and testing environments and were completed succesfully today. You can see the status here: https://virtocommerce.codeplex.com.
As for cspkg, it is generated during actual build, by msbuild. The elastic search ccspkg has to be created differently, as it has to include javaruntime in addition to elasticsearch runtime and packaged into a single setup.
The new, 1.13 version of Virto Commerce by default deploys azure website instead of azure cloud service for website and scheduler (deployed as a web job). Only elastic search is deployed as a cloud service. The setting can be changed in deploy.ps1.
Also make sure to check the complete instructions on how to deploy source code to azure at http://docs.virtocommerce.com/display/vc1devguide/Source+Code+Azure+Deployment.

How do you access rails_env from the Cap deploy command?

In deploy.rb, I believe that :rails_env is typically set by require 'capistrano/rails' found in your Capfile. I am using rails, but not using the built in asset pipeline and therefore, don't use capistrano/rails and was in the predicament of having to manually set :rails_env in deploy.rb when switching between staging and production deploys. This seemed rather silly as the environment is always included when executing cap staging deploy or cap production deploy. I am posting this question, as it seems like it could be a fairly common pain point with a trivial solution, but after much googling, I came up empty-handed. I therefore dug into the Capistrano 3.1.0 source code to figure out how to access the stage variable entered on the command line and will follow up with a brief answer that does a bit of explaining.
The simple answer is to add the following line near the top of deploy.rb:
set :rails_env, fetch(:stage)
The variable :stage gets set in capistrano/setup which is required in your Capfile. This script creates rake tasks for each stage that is defined in config/deploy. Inside the definition for the rake task you will find the following: set(:stage, stage.to_sym) which is the stage/rails_env variable from your cap staging deploy or cap production deploy command.