We have recently added two new conditions – FileContains and NotFileContains – which operate alongside the If command and work on any text based file you choose to specify. As with all commands and conditions in Pipeline Runner what they do should be pretty much self explanatory just from their names, but why did we add them? One of our users wanted to automatically update a source code file which contains a list of version numbers which are associated with database updates. Their software checks against the list and warns the user if any of the database updates have been missed, and will refuse to run until that update has been applied in order to avoid potential damage to data.

In Pipeline Runner that is really easy to do even with a single line of script. Better though to use variables so that you can reuse the information as often as you like later in the script:


[Setup]
Var
:VersionTargetFile=“C:\Source\MyApp\bin\Release\MyApp.exe”
Var:NewVersion=IncrementFileVersion,%%VersionTargetFile%%,Revision

[Update Database Update Version]
AppendText
:“C:\Source\MyApp\Database Update Versions.txt”,%%NewVersion%%,NewLineBeforeIfNotPresent


This simple script retrieves the current version of the file, increments it, and then adds it to the end of the Database Update Version file.

The problem? The customer uses the Tasks feature in Pipeline Runner to choose which parts of a complex script is run, and on occasions they may find an issue and run part of the script again after disabling the automatic version incrementation for that run. When that happens, the file can contain multiple entries for the same version. How can we prevent that? Simple – use the NotFileContains condition to check if the specified version number already exists anywhere within the file, and only if it does not exist open the file and add the version number to the end:


[Update Database Update Version]
If:NotFileContains:“C:\Source\MyApp\Database Update Versions.txt”,%%NewVersion%%,OrdinalIgnoreCase,AppendText:“C:\Source\MyApp\Database Update Versions.txt”,%%NewVersion%%,NewLineBeforeIfNotPresent


If that looks complicated to you, don’t worry because you don’t even need to type any of it! Pipeline Runner Studio will let you generate the whole thing by simply selecting the necessary parts from a menu or drop down button and it will build it automatically for you…

Pipeline Runner can make short work of even the most complicated requirements and provide complete automation of complex processes with ease. Once a project script is written, you can run it forever either automatically or on demand saving countless hours and removing all the risk of human error that comes with doing it manually.

Responsive site designed and developed by