PowerShell Script Runs correctly in ISE however, it fails through SCORCH Runbook Run .Net Script Activity - orchestration

I am able to run Powershell script in ISE however, same script does not Run through "Run .Net Script" Activity in Orchestrator Runbook. It fails on minor errors where error action Silently continue is defined.
It is not specific to any single script. But, for all.
SCORCH Version 2019

Related

TFS Build: stuck when running .exe

I run BUILD in TFS, and one of the steps contains executing the .exe file.
If i run this .exe file separately, on the remote PC where BUILD is running, it operates correctly and successfully.
But when it is being called from BUILD, it simply gets stuck on this stage.
I used debug mode, copied exactly the command it is running of this type:
C:\Windows\system32\cmd.exe /c "C:\Agents\Agent2.....<my path>...\my_file.exe"
Copied it, used the Win+R (run), pasted - it works perfectly.
When can't the BUILD run the .exe file?
Thanks.
I suppose because the application is trying to do something UI-y. The agent is running as a service and any application running during the build should not use the UI in any way. Anything that relies on Windows Forms, WPF or the Message Pump won't work as long as the agent isn't running Interactively.
Try running the exact command from a scheduled task, that should also allow you to test non-interactively.

launch a .bat in TFS2015 build

I have a problem trying to launch a server via a .bat file during a TFS build.
I usually launch the server via a cmd window and it works fine.
When I set it in the TFS build, I end up with the following message :
"'..\server_common.bat' is not recognized as an internal command or external, an executable or a command file".
I also have the following line:
"java -Dsun.lang.ClassLoader.allowArraySyntax=true -Xbootclasspath/a:..\..\..\lib\framework\serverjvm15.jar; -cp ..\..\..\lib\framework\fwtime.jar;" indicating a java syntax error (? I'm not skilled in java)
This batch calls other .bat files and sets java VM-related environment variables
From my research, it is probably a problem of rights as I don't have admin rights when I use TFS. However, all the other steps in the build work fine (installing and launching an appli through command lines, or launching a python script via command lines).
However I also tried to launch a basic script with the same kind of step and it works.
First, suggest you to follow the tutorial in Batch script. Make sure you have meet the requirements of Arguments and used correctly. Such as
Path
Specify the path to the .bat or .cmd script you want to run. The path
must be a fully qualified path or a valid path relative to
the default working directory. In Team Foundation Build, this
directory is $(Build.SourcesDirectory).
Also RDP to your build agent and use your build service account manually run the server_common.bat to narrow down if the account have enough permission.

How can I get a long running PreBuildEvent to output data while its running, instead of after?

I have a visual studio MVC project and I use NPM and Bower. I restore my NPM and Bower packages as part of my build process via a pre-build command line, so the people that use the project don't need to know about npm install, etc.
Unfortunately, for whatever reason, the output is not rendered to the output window until after the package restore has finished. When building a project for the first time, this can take a very long time and I don't want to leave my users hanging, waiting for visual studio to respond.
Is there a way I can set up my pre-build command line prompt to write to the output as it runs, rather than after it runs?
csproj call to run the command
<PropertyGroup>
<PreBuildEvent>
cd "$(ProjectDir)"
echo "generating output for the output window prior to running the long running process"
dir
echo "now running long running task"
call pre-build.bat $(ConfigurationName)
</PreBuildEvent>
</PropertyGroup>
As you can see, I have some debug output in there, a couple of calls to "echo" and a dir call. I would expect to see those commands output to the output window prior to the long running task, but this doesnt happen. Instead I just see the following output until after the package restore runs
1>------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
Because I'm not seeing output from the echo's and the dir, I'm thinking there is either a different way to run this task, or VS / MsBuild just doesnt support showing the output I want until after the task is run. Does anyone know how to set it up to write the output as the task runs?
Use the Target & Message elements:
<Target Name="UserMessage" BeforeTargets="Build">
<Message Text="Your message here" />
</Target>

Running a Windows batch file in Jenkins

I trying to run my Tests cases for a project in Jenkins through DOS Command line on Windows server . I am using Jenkins ver. 1.559.
I am trying to run a Windows batch file through a Jenkins job that has the java command.
Under the "Build" section >> "Execute Windows Batch command" >> Command: call E:\Jenkins\App\UnitTests\App_UnitTests.bat
Save and Build the job.
I am getting an error and here is my Console Output
C:\Program Files (x86)\Jenkins\jobs\App Test Cases\workspace>java.exe -cp "E:\Jenkins\App\PPS\App\bin\;E:\Jenkins\App\PPS\App\lib\junit-4.10.jar;E:\Jenkins\App\PPS\App\lib\*.jar;" org.junit.runner.JUnitCore com.omnitracs.fra.junit.EventTests
'java.exe' is not recognized as an internal or external command, operable program or batch file.
C:\Program Files (x86)\Jenkins\jobs\App Test Cases\workspace>PAUSE
Press any key to continue . . .
C:\Program Files (x86)\Jenkins\jobs\App Test Cases\workspace>EXIT
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
The java command runs fine outside Jenkins.
I have set the JAVA_HOME for the local user and also the PATH variable to point to where java.exe is.
What am I doing wrong? Please help.
For a windows environment, there is some extra configuration needed for more advanced builds. Ultimately you have two options
From Jenkins, The Definitive Guide:
This basic installation will work fine in a simple context, but you
will often need to fine-tune your service. For example, by default,
the Jenkins service will be running under the local System account.
However, if you are using Maven, Jenkins will need an .m2 directory
and a settings.xml file in the home directory. Similarly, if you
are using Groovy, you might need a .groovy/lib directory. And so on.
To allow this, and to make testing your Jenkins install easier, make
sure you run this service under a real user account with the correct
development environment set up. Alternatively, run the application as the
system user, but use the System Information page in Jenkins to check
the /Users/johnsmart/Projects/Books/jenkins-thedefinitive- guide
directory, and place any files that must be placed in the user home
directory here....
To configure your Jenkins server to run under a service account (The suggested option), Install Jenkins as a service, and under the services properties set the log on user info.

Start Selenium test cases using jenkins

I have prepared a test cases using selenium webdriver and I ran locally using MSTEST and it works fine and now I would like to move my test cases to JENKINS, and when i run from JENKINS it says Starting execution... and its more than 15 mnts and still the same status so I have to stop it manually.
here is my console output:
Started by user anonymous
Started by user anonymous
Building in workspace D:\Jenkins\jobs\Selenium_Script\workspace
[workspace] $ cmd /c call C:\Users\XXXXXXX\AppData\Local\Temp\hudson4765437871038045571.bat
D:\Jenkins\jobs\SelScript\workspace>call "D:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\mstest" /testcontainer:D:\Sel\EmployeeTest\test.emp.admin.dll
Microsoft (R) Test Execution Command Line Tool Version 10.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading D:\Sel\EmployeeTest\test.emp.admin.dll...
Starting execution...
Build was aborted
Finished: ABORTED
I wanted to execute the test case on Jenkins and check the result of execution
and here is my code I'm using just in case.
This is what I am using to instantiated my driver, do I have to use RemoteDriver?
public static IWebDriver GetDriver()
{
string _url = new Uri(Common.Url).DnsSafeHost.ToString();
switch (Common.BrowserSelected)
{
case "ff":
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.http.phishy-userpass-length", 255);
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", _url);
drv = new FirefoxDriver(profile);
break;
case "ie":
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
drv = new InternetExplorerDriver(options);
break;
case "chrome":
//_driver = new ChromeDriver();
break;
}
return drv;
}
You can run your Selenium scripts in the Build section of Jenkins.
Click on Add Build Step and select Execute Shell, over there you can directly run your commands as you would type in a Linux environment.
All of this assuming you are running your Jenkins of a Linux environment.
#Do I have to use RemoteDriver?
Depends do you have xvfb installed to run your tests in a headless mode?
If not, then yes, you can redirect your tests to run remotely on a windows/mac machine.
UPDATE
If you have a windows machine, you do not need xvfb. So forget about that.
Shell script (defaults to sh, but this is configurable) for building the project. The script will be run with the workspace as the current directory. Type in the contents of your shell script. If your shell script has no header line like #!/bin/sh —, then the shell configured system-wide will be used, but you can also use the header line to write script in another language (like #!/bin/perl) or control the options that shell uses.
By default, the shell will be invoked with the "-ex" option. So all of the commands are printed before being executed, and the build is considered a failure if any of the commands exits with a non-zero exit code. Again, add the #!/bin/... line to change this behavior.
As a best practice, try not to put a long shell script in here. Instead, consider adding the shell script in SCM and simply call that shell script from Jenkins (via bash -ex myscript.sh or something like that), so that you can track changes in your shell script.
Example -
You can run a ruby command like so
ruby testscripts.rb
or a shell script like so
./testscripts.sh
Jenkins is super easy. Just do this:
1. Allow Jenkins to check-out your code into the Jenkins workspace.
2. Navigate to that workspace on your Windows computer and manually run
the tests by executing the script that starts them.
By doing it this way Jenkins is temporarily out of the picture and is therefore no longer the cause of your problem. Then, you can focus on what the real actual problem is. Once you have resolved the problem, check your changes into your source code repo, then run the Jenkins build again and try to run manually again. If that also works, THEN finally, you are clear to setup a build task in Jenkins to run your test.

Resources