How to configure Nant plugin in Jenkins - nant

I have Jenkins with Nant-plugin. I have one job with nunit tests. When building the project I get an error:
Executing command: cmd.exe /C ""NAnt.exe ./nant.build && exit
%%ERRORLEVEL%%"" [GuiTests] $ cmd.exe /C '"NAnt.exe ./nant.build &&
exit %%ERRORLEVEL%%"' 'NAnt.exe' is not recognized as an internal or
external command, operable program or batch file.
Does it mean that I should install nant and manually set up environment variable? So why Nant-plugin?

Yes, like ANT plugin it requires an external installation. You can configure an automatic installation on the main Jenkins configuration page (http://<jenkins-server>/configure, search for Nant Builder), but in my experience it is better not to get involved with Jenkins automatic installations - they are rather quirky.
The reason for the plugin is portability of your builds. With the plugin you do not have to specify different build steps for, say, your Linux (Execute Shell) and Windows (Execute Windows batch command) builds, but rather can use the same Execute NAnt build step.

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)

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 do I read a Linux environment variable into install4j

My application sets CLASSPATH in a shell script named shrc that sets up the environment to run java commands. Is there an easy way to pass the CLASSPATH used in an installed application to install4j so I can use it in an action? The working solution I have uses "Run executable or batch file" to run a script that does this:
. ./shrc
${APPHOME}/jre/bin/java -cp ${CLASSPATH} ...etc...
I do this within an add-on installer, so the shrc already exists, but I need to run some of the existing java code to configure the patches.
It seems to me there must be a better way to do this that would work on Windows also. Any help is appreciated.
To read environment variables, use
System.getenv("CLASSPATH")
If you would like to use it as an install4j installer variable, add a "Set a variable" action with the above line as the script.

How to further automate Teamcity

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.