Unable to locate file 'C:\BuildAgent\temp\buildTmp\SYSTEM_[AGENT NAME] 2013-02-06 16_25_11\ - teamcity

I have an MSTest build step in my TeamCity build. Some of the tests are looking for a file in a relative path which they cannot find and the tests are throwing the error...
Cannot find path...
'C:\BuildAgent\temp\buildTmp\SYSTEM_[AGENT NAME] 2013-02-06 16_25_11\Documents\json.value.list.txt'
I have a PowerShell script that I want to use to create and copy the file out to the above path. However, I cant seem to figure out the appropriate TeamCity parameters to use to construct the path...
I have...
%system.teamcity.build.tempDir%\%teamcity.agent.name%\documents
However, that gives me...
'C:\BuildAgent\temp\buildTmp[AGENT NAME]\Documents\'
What can parameters or TeamCity variables can I use to construct...
C:\BuildAgent\temp\buildTmp\SYSTEM_[AGENT NAME] 2013-02-06 16_25_11\Documents
Thanks!

If your test is reading the contents of a file, this will ensure that relative paths are resolved correctly so tests can be run on TeamCity as well as locally:
string currentDir = new System.Diagnostics.StackFrame(true).GetFileName();
var workingFile = new FileInfo(currentDir);
string fileContents = File.ReadAllText(workingFile.Directory + relativeFilePath);
relativeFilePath is the variable containing the file. fileContents will contain the contents of this file when run from TeamCity or locally.

Related

I can't export a custom report name from html-reporter-extra

This really should be straightforward but I can't get it to work.
It's a simple setup: I have a locally run Jenkins, exported Postman collections that I'm running using newman. I got html-report-extra installed and it's generating a report but I can't get it to export the html file under a different name!
I have a locally installed Jenkins, I'm using a freestyle project and under Build - Execute Windows batch command I have this:
newman run IDMS4.postman_collection.json -e IDMS4.postman_environment.json --reporters cli,htmlextra --reporter-html-export newman/index.html --disable-unicode
This is how my Jenkins job is setup:
Jenkins job setup
Build completes but there is no index.html anywhere. This is the the part that's puzzling me.
In
.jenkins\jobs\Newman runner\htmlreports\HTMLReport
i get the default file format name (project name + timestamp).
In
.jenkins\workspace\Newman runner\newman
I also get project name + timestamp html files.
Why is this outputed to both folders and how can I get this to export just one index.html?
Please try with dot slash. eg: ./newman/index.html.
and also
if you need collection name to be in the report, please use following node module
https://www.npmjs.com/package/jaiman

How to reference script files in webpack deploy?

I am using webpack and electron and while I can reference my script files fine locally (app/scripts/scriptname.sh), when it comes to the production deploy, I get an error: Can't open app/components/scripts/scriptname.sh.
It's unclear to me if this is an electron-dependent issue or a webpack-issue.
I am running these using node child_process as:
var ls = spawn('sh', ['app/components/scripts/scriptname.sh']);
I don't necessarily need the scripts to be in their own folder it would just be helpful.
You need to provide the complete absolute path to the script. To do that you can use the app.getAppPath() API of electron
app.getAppPath()
Returns String - The current application directory.
So your code would be something like:
var scriptAbsolutePath = app.getAppPath() + '/app/components/scripts/scriptname.sh';
var ls = spawn('sh', [scriptAbsolutePath]);
You can also have a look at app.getPath(name) API if it satisfies your particular requirement.

Jenkins archive single file not working

I'm trying to archive a zip file in Jenkins using the archiveArtifacts step like this:
archiveArtifacts 'publish\\archive.zip'
But I keep getting this error:
Archiving artifacts
ERROR: No artifacts found that match the file pattern "publish\archive.zip". Configuration error?
ERROR: ‘publish\archive.zip’ doesn’t match anything: ‘publish’ exists but not ‘publish\archive.zip’
The file definitely exists. If a tack an asterisk onto the end of the path like this:
archiveArtifacts 'publish\\archive.zip*'
the step works fine and the file is archived but why is this necessary?
My best guess is that you have non readable char at the end of the filename or elsewhere in your script. I used to get some confusing script errors when writing scripts on windows and putting them on a linux environment. In IntelliJ you can change theese via file->line seperators->unix.

accessing App.Config file after deploy in C#

Im using below code to update app.config's some values( I have config file path in the app.config file).When deploy its getting errors I think its becouse app.config file change in to an exe. how to change my code work as debug time as well as deploy time
var appPath = ConfigurationManager.AppSettings["configPath"].ToString();
string configFile = System.IO.Path.Combine(appPath, "App.config");
var configFileMap = new ExeConfigurationFileMap();
configFileMap.ExeConfigFilename = configFile;
System.Configuration.Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
config.AppSettings.Settings["InvoiceInterval"].Value = InvoiceIntervalVal.ToString();
Hi thanks every body for instance reply. I fix my own problem it was just a confusion. I was a java guy and I new to .net in .net App.config file compile and create .config in Debug folder file even though debug it access that .config file in Debug folder . So actually when if you change the value in App.config in programatically it doesn't change the App.config file. it change the .config which is in debug file.its like [project name].vshost.exe.config in debug folder.
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["InvoiceInterval"].Value = InvoiceIntervalVal.ToString();
config.AppSettings.Settings["directPaymentInterval"].Value = directPaymentIntervalVal.ToString();
config.AppSettings.Settings["paymentStatusInterval"].Value = paymentStatusIntervalVal.ToString();
config.Save();
ConfigurationManager.RefreshSection("appSettings");
using above code you can able change App.config file's value in debug time also in run time. but those changes not seems in App.config file. but you can see changes in exe file which it is belongs to.In my case it was in src\Vetserve.Credicare\bin\Debug\Vetserve.Credicare.vshost.exe.config
Perhaps try and set your App.config's file 'Copy to Output Directory' property to 'Copy always'.
Reference: AppConfig file not found in bin directory
After compilation App.Config will be available as
YourConsoleApplication.exe.Config inside application bin.
You can do like:
var beforeInvoiceInterval = ConfigurationManager.AppSettings
["InvoiceInterval"].ToString();
ConfigurationManager.AppSettings["InvoiceInterval"] = "Your value";
var afterInvoiceInterval = ConfigurationManager.AppSettings
["InvoiceInterval"].ToString();
afterInvoiceInterval will contain the value you assigned but it'll not
modify YourConsoleApplication.exe.Config.

How to get the absolute folder location of a Jmeter .jmx project file from within itself?

I have a Jmeter project that is executed by Maven and is able to locate external Beanshell scripts by the path src/test/jmeter/external-scripts-dir/script1.bsh , but when I run Jmeter directly in the GUI on my computer the relative location doesn't work and the tests cannot be ran standalone. This forces me to run Jmeter from Maven.
So, I have a project file located at a Maven layout location like C:\files\git\projectA\src\test\jmeter\Project.jmx but since I ran jmeter from its installation folder at C:\Jmeter2.12 , it cannot find the relative location of the external script I mentioned earlier.
To solve this, all I need is to set a variable to the directory containing the .jmx file. Is there any possible way to do this?
I can dynamically determine the home of Jmeter ( C:\Jmeter2.12 ) pretty easily (using the following code) but that doesn't help me get the location of the project file.
${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer
.getFileServer().getBaseDir();)}${__BeanShell(File.separator,)}
Is there something similar to the above code that would allow me to deduce the project file location?
If you're looking for the way to locate current script when you run JMeter in GUI mode you can try the following Beanshell expression:
${__BeanShell(import org.apache.jmeter.gui.GuiPackage;GuiPackage.getInstance().getTestPlanFile();)}
If you brake this down into 5 lines there will be:
import org.apache.jmeter.gui.GuiPackage;
import org.apache.commons.io.FilenameUtils;
String testPlanFile = GuiPackage.getInstance().getTestPlanFile();
String testPlanFileDir = FilenameUtils.getFullPathNoEndSeparator(testPlanFile);
vars.put("testPlanFileDir", testPlanFileDir);
log.info("testPlanFileDir:" + testPlanFileDir);
Your current .jmx file fill be stored as scriptFile JMeter Variable.
References:
GuiPackage class JavaDoc
How to use BeanShell: JMeter's favorite built-in component guide
The solution was (thanks to Ardesco) to do the following:
Use the following variables, set in the Test Plan global variables:
projectHome = ${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}
jmeterHome = ${__BeanShell(System.getProperty("user.dir");)}
scriptHome = ${projectHome}/scripts
Thanks to the accepted answer, I was able to solve a related problem.
Now, I can calculate this parameter once and re-use it as a user variable.
JMETER_SCRIPTS_DIRECTORY=${__BeanShell(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();)}
Its usage is ${JMETER_SCRIPTS_DIRECTORY}.
Interestingly, it works in both GUI mode and NON GUI mode (from command line).

Resources