File Exist condition issue in Jenkins - jenkins

I am working on product testing automation. I am using Jenkins to create a job that will first browse some file in a directory. But I got a problem with Conditional Step in File Exist condition. It is not working when I search *.job file, it only works with specific file name I put. Sorry I don't have enough reputation to post picture :)
Anyone can help me solve this issue. Thank so much for reading

I don't think File Exists supports more than one file, you could try the "File match condition". Definitions below:
File exists Run if the file exists.
The file is expanded using the Token Macro Plugin. If the file is
relative, then it is relative to the Base directory. If the file is
absolute, then it will be tested on the Node that contains the Base
directory (the master for $JENKINS_HOME and Artifacts dir).
Files match Run if one or more files match the selectors.
Separate multiple includes or excludes patterns with a comma. e.g.
Includes "target/site/**/*.html,target/site/images/" Excludes
"**/*.gif" If no includes pattern is configured, then the pattern
"**" will be used, which matches all files in the directory and all
sub directories. The includes and excludes are Ant Patterns.

Related

Custom houdini module path

I need to store Houdini *.hda files on a network share.
This folder needs to be sourced by all users.
Usually, for those kind of requests, I use an environment variable in ~/houdini17.0/houdini.env like for exemple:
HOUDINI_TEMP_DIR="/my/custom/temp/path"
But the issue is that I can find a solution for hda/otls files.
Adding it to HOUDINI_PATH="${HOUDINI_PATH};/my/custom/hda/path" or HOUDINI_OTLSCAN_PATH doesn't work and worst, it seems to break other links since a few other houdini nodes aren't available anymore.
Can someone point me to the right environnement variables?
Try using $HSITE and/or $JOB environment variables. Houdini will scan sub folders of the paths defined by $HSITE and $JOB for all relevant files and folders so you don't need to set a bunch of different env vars. You can mirror the folder structure found in C:\Users\username\Documents\houdini16.5
Obviously replace the Houdini version with yours. Also note that $HSITE needs to point the the folder that contains the houdini16.5 folder not the folder itself. This way you can support multiple houdini versions with a single env var.
http://www.sidefx.com/docs/houdini/basics/config.html
For example if $HSITE= //myNetworkShare/Houdini
You would need this folder structure:
//myNetworkShare/Houdini
/Houdini16.5
/otls
/scripts
/python2.7libs
/.....
Note you can only give $HSITE a single path.

TFS Copy Files action exclude syntax

I'm trying to understand the logic behind TFS 2013 Copy Files action's Content filter syntax. I have a simple solution with a couple of projects and some test projects, which unfortunately have huge test files. I don't want the test projects or the files in the drop folder. Test projects are named like Project.Test, Project2.Test etc.
I tried to filter them like this:
**\bin\$(BuildPlatform)\$(BuildConfiguration)\**;-:**\*.Test\**
But this doesn't copy anything.
Test files are located in directories called TestFiles.
This also filters out everything:
**\bin\$(BuildPlatform)\$(BuildConfiguration)\**;-:**\TestFiles\**
If the first part matches the correct files in bin directory, how can the second part them filter them out? I don't see how that can match the same files.
Solution to my problem was to use a different syntax to exclude certain directories (*.Test here):
**\!(*.Test)\bin\$(BuildPlatform)\$(BuildConfiguration)\**

Jenkins thinBackup - include additional folder

When using the thinBackup Jenkins plugin one can configure it to include additional files. It seems impossible to include whole additional folders though.
In our case (see screenshot below) it is adding the secret.* files properly but does fail to include the secrets folder (or in the case shown here the .key files in the secrets folder).
Are we configuring this wrong or is it just not possible to include arbitrary folders?
I played around with regex and if you want to backup all the files in secrets folder, try below regex.
It works fine
^(.*\.xml)|^(secrets|.*\.key|.*\.KEY|.*\.Secret|.*\.secret|.*\.mac|.*\.MAC|.*\.seed|.*\.crumbSalt|.*\.consoleAnnotator|.*\.serverCookie|.*\-switch|whitelisted\-callables\.d|.*\.conf|filepath\-filters\.d|.*\.conf)$
You actually need to use the vertical bar to represent a folder or subfolder. I believe the fix for your regex in the screenshot would be changing (secrets/.*.key) to:
(secrets|.*\.key)
Any further subfolders have a similar syntax, such as getting *.groovy from jenkins/scriptler/scripts/:
(scriptler|scripts|.*\.groovy)
Maybe you've already figured this out, but if not, I hope this helps.
Bill

Attachment using Editable Email Extension in Jenkins

I am using Editable Email plugin in Jenkins to attach a file with the email. The problem is that the plugin is unable to find the file to attach.
My file structure is like this -
ReportDirectory
workspace
ReportDirectory contains the report which I want to attach. I believe that the base directory for the plugin is the workspace. So I am giving the attachment location as
../ReportDirectory/DemoReport.html.
I have also tried
ReportDirectory/DemoReport.html
and many more options.
Am I doing something wrong?
I figured it out.
The Editable Email plugin uses the Ant File Syntax for locating the attachment. When I took at the documentation for Ant File Syntax ( http://ant.apache.org/manual/dirtasks.html ), it says that
In general, patterns are considered relative paths, relative to a task dependent base directory (the dir attribute in the case of ). Only files found below that base directory are considered. So while a pattern like ../foo.java is possible, it will not match anything when applied since the base directory's parent is never scanned for files.
Since the base directory in this case is the "workspace" and my directory "ReportDirectory" is not located in it so the Ant is not able to access it.
Two solutions exist:
Move the "Report Directory" somewhere in "workspace". I did not prefer this because I did not want to mess up the workspace.
Once the report has been created in "ReportDirectory", use your Ant\MSBuild script to copy it temporarily in the "workspace" and then the Email plugin shall be able to access it by something like **/Report.html or something.
#Amey - thanks for your efforts though :)
Another solution is create a symbolic link from $JENKINS_HOME/jobs/workspace/$workspace_name to the path with your $workspace_name. This way worked for me.
ReportDirectory/DemoReport.html
is the correct way to do it.
Please keep in mind that the path to the file and the file name is case sensitive so I assume your entering the correct name.
One more thing is to check is that the report is actually created and is located at the path mentioned by you.
Another thing you could try
ReportDirectory/*
Jenkins will use the directory available in its workspace.
You can send multiple attachments as below.
reportFolder/html/index.html, screenShotsFolder/screenShots/*.jpg
Simple answer:
Copy your file into the workspace(into your job directory), then under Attachment, just give the file name without any quotation or anything. This will automatically tell Jenkins to pick up your file. That's it!
Pls don't confuse yourself after seeing all the configurations.

Nunit Relative Path failing

I'm having an issue with Nunit where I cannot find an image file when I run my tests and each time it looks for images it looks in the Nunit folder instead of looking inside the folder where the binary resides. Below is a detailed description of what's happening.
I'm building a binary that is under test which contains the definition for some game elements and png files which will define the sprites I'm using (for sanity sake call it Binary1)
Nunit runs tests from a seperate binary (Binary1Test) executing test methods against the first binary (Binary1).
All tests pass, unless the test executes code in Binary1 which then requires Binary1 to use one of the image files (which are defined via a relative path). When the method is called, Nunit throws a file not found exception stating that it cannot find the file and states it's looking inside of the Program Files\Nunit.net 2.0 folder
So I have no idea why the code is doing this, and to make matters more confusing when I pull up Enviornment.CurrentDirectory it gives me the correct path (the path to my debug folder) and not the path to nunit. Also if I use this instead of using the relative path, my tests will run without issue. So my question is, does anyone know why in the case of loading relative paths from within my binary that nunit decides to use it's directory instead of the directory where the binary is located and where the images are stored? Thanks.
I'm not sure why this is happening, but wanted to mention something that might help you troubleshoot a little. Do you have any Path Constraint assertions in your tests? It might help you troubleshoot this.
Here's the NUnit.org link for the syntax: http://www.nunit.org/index.php/extensions/docs/2.4/files/index.php?p=pathConstraints&r=2.5.1
Here's an example (from the above link) of the syntax for relative paths. You might want to assert that your relative path is the same as an absolute path and see what is going on. At least you'll have a specific failing test about paths that you'll need to get passing.
Assert.That( "/folder1/./junk/../folder2",
Is.SamePath( "/folder1/folder2" ) );
Assert.That( "/folder1/./junk/../folder2/x",
Is.Not.SamePath( "/folder1/folder2" ) );

Resources