How to further automate Teamcity - deployment

I have successfully configured my project for build in TeamCity. Going a step more, I want to run a deployment script once a build completes successfully. The deployment script is a simple bash command. To make the question more simpler, how would I invoke a shell command once a build successfully completes in Teamcity.
Please help

TeamCity 6.0 has a new feature called Multiple Build Steps:
Multiple Build Steps: Now any build configuration can be comprised of unlimited number of build steps, where each step is represented by a build runner. Don’t limit yourself, and combine as many build runners into one configuration as you need. Feel free to call a NAnt script before compiling VS solutions, run inspections and duplicates finder after your ANT build, add NUnit tests after your Rake build, and so on.
So you can add a new build step with the command line runner which will execute your shell script.

Related

Azure DevOps Release Pipeline Inline Powershell script failing to run python unittest suite

I have a release pipeline setup in Azure DevOps to run a regression test suite. I am running these tests remotely on a Microsoft self-hosted Windows Agent using Selenium (Python bindings) and the Python unittest framework, which invokes chromedriver.exe to run tests.
When the release job reaches the task Run Python Unit Tests however, it freezes and I don't see any output (although, when I open the task manager on the agent
I can see chromedriver and chome instances running which suggests that something is happening).
Other info -
I am able to connect to the agent sucessfully as all my repos and latest commits are pulled down (from an earlier task in the pipeline)
the Chromedriver path is set as an environment variable on the agent
I am using Chromedriver 2.43
I am using Python 2.7.14 as the interpreter (also set as an env variable in the Path)
The inline powershell task has the following in the Script to run field -
cd C:\path\to\folder\with\tests
python tests.py staging
The message displayed when this task runs in DevOps pipeline is -
Waiting for console output from an agent...
console output
When I run the tests locally on the agent with the exact same command (opening the cmd.exe terminal on the agent), I can see chromedriver opening and the tests running as expected (with output in the terminal too)
Why am I unable to run see these tests running when invoked from the inline powershell task in the release pipeline but able to see the tests run when invoked on the VM? And why does the output still not show as the tests are running?
(I have also tried a normal cmd.exe task in place of the inline powershell task, the same issue was encountered)
Any help would be much appreciated, thank you :)
EDIT:
Ran a simple selenium test to check everything was working and got a successful result. However -
I was still unable to see console output as the test was executing
I was still unable to "see" anything executing on the VM (so it appeared to be running as a background task but could not see chrome launching and navigating to pages etc)

What's the best way to run a linqpad script from your release pipeline?

I have a linqpad script which we need to run as part of our release, from VSTS. Best way I can think of is to run this as a Powershell script. There seem to be 2 options to be able to do this
Linqpad's native lprun.exe
Linqpadless lpless.exe
The problem with these however is that I will have to install these on the Build/Release VMs for each environment, which is what I'm trying to avoid at the moment.
Linqpadless does distribute a nuget package but I don't know how to run that from powershell/release pipeline.
Has anyone done something similar. What's the best way to achieve this?
You can add three tasks in your build definition to do this:
Nuget Task to install linqpadless package:
Command Line task to run lpless.exe:
Command Line task to run the script generated by lpless.exe in last step:
If you want to use Powershell script, you just need to call these command in the script one by one.

Run powershell build step in VSTS agent installed on mac?

I installed VSTS build agent on mac to build xamarin iOS project. Builds worked fine until I added powershell build step.
Even though I installed powershell for mac (https://github.com/PowerShell/PowerShell) and re-installed the agent, VSTS complains it does not have agent that is capable to run the build.
No agent could be found with the following capabilities:
DotNetFramework, Xamarin.iOS, npm
When I disable the build step, builds work just fine.
Is it possible to run powershell build step on Mac?
As MrHinsh clarified, the PowerShell task cannot be used on Mac.
As a workaround I used ShellScript task:
With the following bash script:
#!/bin/bash
powershell ./SetAppVersion.ps1
Also, the powershell installer did not seem to add powershell to my PATH so I had to add it:
$ export PATH=$PATH:/usr/local/microsoft/powershell/6.0.0-alpha.16
If you're sure that DotNetFramework is installed then you can go to the Agent Queues settings and add a custom Capability to it called exactly that.
That should allow it to run but it might fail after that if the agent can't actually find them, but it might also succeed so it's probably worth a try.
No, you can't use a PowerShell task on a Mac, only node tasks are supported.
PowerShell tasks as currently written in PowerShell3 which is not supported on Mac. You can request that the team implement this on http://visualstudio.uservoice.com
In TFS build go to Agents Queues=>Capablilities=>Add variable named as DotNetFramework and give value for mac agent's dotnet framework path.
It's fix for the issue "No agent could be found with the following capabilities:DotNetFramework"
This is a follow-up to the accepted answer to address a question in a comment which I also had.
Thanks to spatialguy for posting and finding a simple solution to this problem. I had the same problem as KeithA45:
QUESTION: What if you wanted to do the same, but also pass arguments to the Bash script which passes them to the Powershell script?
I found a solution to this, first off, I modified the shell script task to include the Visual Studio Team Services (VSTS) environmental variables that I wanted to pass to the powershell script.
Next, I pass the arguments through to the called powershell script by slightly modifying the shell script mentioned by the accepted answer.
#!/bin/bash
powershell ./Version.ps1 $1 $2
Finally, in the powershell script, I catch the arguments that have been passed through using using param like this:
param([string]$version, [string]$path)
Wherein I can now use the variables $version and $path which contain the original arguments entered in VSTS to the needs of my powershell script.
Things seem to have moved forward because I ran successfully today a PowerShell#2 task on a Mac Self-Hosted Agent from an Azure DevOps build pipeline.
By checking "Enable system diagnostics" when queuing the build, the log shows me that the task found itself the path to the PowerShell Core (pwsh) that I installed on my Mac with the help of Homebrew (brew cask install powershell - see https://learn.microsoft.com/fr-fr/powershell/scripting/install/installing-powershell-core-on-macos).

Can we choose environment(endpoint) from Jenkins to run ReadyAPI tests?

I'm trying to run tests from Jenkins integrated with ReadyAPI and Maven.
currently, i'm switching the environment from a database and running the testcases.
Now, we want to choose the environment from Jenkins, is there any possibility to do so ?
Thanks
You can pass the environment to the command line test runner by using the
-E YourEnvironmentName
parameter.

How to integrate Perl automation test script with TeamCity build

I have a Rest API. I wrote my test automation in Perl which sends curl commands. I want to integrate the tests with TeamCity build so that any change in the code will be pulled, installed in a machine and the tests will be run. If all the tests pass then only the build will be green in TeamCity.
Now I don't know how to integrate Perl with TeamCity. Is there any plugins available for this?
You can use the Teamcity plugin for Perl to integrate your perl tests with Teamcity. If you use this ,
The test results are displayed in a nice Teamcity Tests tab witch a breakdown for Success, Failed and ignored tests.
You can go into the history of tests to know exactly when a change started breaking someone's tests.
You get a log info per each test which is useful for debugging when you have multiple tests.
The documentation for the plugin at the CPAN page has good examples of how to implement this
You can use the Command Line Runner to execute a Perl script. If it returns a non-zero exit code the build will fail. See https://confluence.jetbrains.com/display/TCD8/Configuring+Build+Steps:
The build step status is considered failed if the build process returned a non-zero exit code and the Fail build if build process exit code is not zero build failure condition is enabled (see Build Failure Conditions); otherwise build step is successful.