I need to create a custom stamp for the day of the week, which is to be appended to the filename.
Suppose If it is sunday , the value of the stamp must be "1",
same way if its monday the value of the stamp must be "2".
Is this possible in MQFTE using Ant Script???
You can't do this directly with standard TStamp task. That allows you to format your timestamp using patterns defined in SimpleDateFormat, and there is no format symbol for day of week as a number.
I guess you could write a custom TStamp task.
However, this works.
Create a set of properties files, named using 3-letter day name:
$ find daysOfWeek/
daysOfWeek/
daysOfWeek/Fri.properties
daysOfWeek/Mon.properties
daysOfWeek/Sat.properties
daysOfWeek/Sun.properties
daysOfWeek/Thu.properties
daysOfWeek/Tue.properties
daysOfWeek/Wed.properties
In each file, define a single property for the corresponding day number, e.g.
$ cat daysOfWeek/Thu.properties
day.num=5
In your build script, first get a property matching today's day name, then load the corresponding properties file, then you can reference the day.num property.
<project>
<tstamp>
<format property="day.name" pattern="E" locale="en/US"/>
</tstamp>
<property file="daysOfWeek/${day.name}.properties"/>
<echo message="${day.name}"/>
<echo message="${day.num}"/>
</project>
Output today (Thursday) is
$ ant
Buildfile: build.xml
[echo] Thu
[echo] 5
BUILD SUCCESSFUL
Total time: 0 seconds
Related
I have a project with documentation written in ReStructuredText. The docs are compiled to HTML when the project is built via cmake. It includes a line with a "last changed" date.
I wonder how hard it would be to set this date automatically, as, from time to time, I simply forget to update the last changed date when I edit the docs.
I thought about generating some additional file, like
date -d "#$(stat -c %Z Readme.rst)" +"%d.%m.%Y" > lastchange.txt
and to reference it in the source like
:Date: .. include:: lastchange.txt
But would it be possible to achieve such a reference with only RST? Or in a more elegant way? Because doint it like so, it would be necessary to create a "working copy" of the sources in the cmake build directory, because otherwise the reference won't be found. And if I do this, I can as well sed the date into the sources directly.
I want to be able to set the target's filename to be a fixed name that includes the process's start time and date even if the configuration file is updated due to autoReload="true" being in the nlog intro.
I have tried the following but it recreates the log file when the log file is altered.
<target
name="file"
xsi:type="File"
fileName="C:\Logs\${cached:cached=true:inner=${date:format=yyyyMMdd.HHmmss}}.${processid}.txt"
layout="${time} ${level}: ${message}">
</target>
Is there a way that I can get a time and date that is essentially fixed for the duration of the process no matter how many times the config file is updated and incorporate it into the filename?
You could pass a custom parameter to NLog, containing the process start date and time.
GlobalDiagnosticsContext.Set("ProcessStart", yourDateVariable);
logger.Debug("Hello world!");
And then use that as part of the filename.
${gdc:ProcessStart}
I'm trying to set a bamboo global variable in a script contained in a batch file. Here is the batch file:
#echo off
echo Initial Date: %bamboo_releaseDate%
for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (
set dow=%%i
set month=%%j
set day=%%k
set year=%%l
)
set mydate=%year%%month%%day%
echo %mydate:~2,6%
set bamboo_releaseDate=%mydate:~2,6%
echo Set up date: %bamboo_releaseDate%
And here is my output:
Initial Date: 140617
140619
Set up date: 140619
However, as soon as the script is run, Bamboo puts back the old value. Is there a way to avoid that? How would you suggest to do it?
My goal is to have one folder per nightly build with the date in the name of the folder. I use therefore the standard 'Artifact download' from Bamboo and give some parameters for the name of the containing folder.
Depending on your version of Bamboo, you could use ${system.} to store values for later use. More details here: https://confluence.atlassian.com/display/BAMBOO/Bamboo+variables
Is there a reason you want to over-write the bamboo.releasedate value? If you have builds that start on the evening and finish in the morning, you could pass an artifact to each successive build to get the release date. However, if you can run all your builds on the same day, change the start time and reset your batch file to build its own date and use that going forward (each time the build runs, it would regenerate the build date).
I'm using fluentmigrator and I'm stuck with a problem I need to create DB script using fluentmigrator each time I run the build script and its done but the problem is I just want to rewrite the script only if the db is altered . How can I achieve that my current code is given below
<Target Name="Migrate" >
<MakeDir Directories="$(OutputFolder)\DBScripts"></MakeDir>
<Migrate Database="sqlserver2008"
Connection="Data Source=ALen-PC;Initial Catalog=TestMigrator;User ID=user;Password=password"
Target="$(OutputFolder)\Release\bin\MigratorTest.dll"
Output="True"
OutputFilename="$(OutputFolder)\DBScripts\DBScript.sql">
</Migrate>
</Target>
At the moment, there is no support for this process in FluentMigrator. You could add a timestamp to the filename and then check the size of the file. If it is very small, less than 200 bytes then throw it away. If it is larger than 200 bytes then the schema has changed so rename the file to DBScript.sql and replace the previous version.
I would recommend submitting this as a feature request for FluentMigrator here.
I need to change only the revision number of an AssemblyInfo.cs file. The version number is in the format Major.Minor.Build.Revision e.g. 1.4.6.0.
Currently I change the version with the FileUpdate task (from the MSBuild Community Tasks Project) and the following regex:
<FileUpdate Files="#(AssemblyResult)"
Regex='(\[\s*assembly:\s*AssemblyVersion\(\s*"[^\.]+\.[^\.]+)\.([^\.]+)(\.)([^\.]+)("\)\s*\])'
ReplacementText='[assembly: AssemblyVersion("$(AssemblyMajorNumber).$(AssemblyMinorNumber).$(AssemblyBuildNumber).$(Revision)")]' />
Now I need to update only the revision number and leave major,minor and build unchanged.
So, is there any task to do this? Or can it be done with a regex? What would be the regular expression then?
How about this:
<FileUpdate Files="Properties/AssemblyInfo.cs"
Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
ReplacementText="$1.$2.$3.$(Revision)" />
I use the following target to do this:
<Target Name="UpdateAssemblyInfoVersion" DependsOnTargets="GetRevision">
<CreateItem Include="**\AssemblyInfo.vb">
<Output TaskParameter="Include" ItemName="AssemblyFiles"/>
</CreateItem>
<Time>
<Output TaskParameter="Year" PropertyName="Year" />
</Time>
<FileUpdate Files="#(AssemblyFiles)"
Multiline="true"
Singleline="false"
Regex="(AssemblyVersion|AssemblyFileVersionAttribute|AssemblyFileVersion)\("([0-9]+\.[0-9]+\.[0-9]+)(\.[0-9]+)?"\)"
ReplacementText="$1("$2.$(Revision)")" />
<FileUpdate Files="#(AssemblyFiles)"
Multiline="true"
Singleline="false"
Regex="AssemblyCompany\(".*"\)"
ReplacementText="AssemblyCompany("My Company")" />
<FileUpdate Files="#(AssemblyFiles)"
Multiline="true"
Singleline="false"
Regex="AssemblyCopyright\(".*"\)"
ReplacementText="AssemblyCopyright("Copyright © 2009-$(Year) My Company")" />
</Target>
This replaces the revision (4th number) in any of the AssemblyInfo files (in multiple projects). It looks at the AssemblyVersion AssemblyFileVersionAttribute and AssemblyFileVersion tags, and uses the $(Revision) MSBuild property for the number (I have another target called GetRevision that gets this from SVN and sets the property, so this one depends on that target). The regex replacement handles version numbers that have either 3 or 4 digits (I had a bunch with 3 only, for whatever reason).
It also sets/overwrites the Company and Copyright information, and sets it to "My Company". For copyright, I was lazy and made it so it always uses the current year so I don't have to remember to update it every year (so it says eg "Copyright (c) 2009-2010 My Company").
This target requires the MSBuild Community tasks extension.
As a matter of policy, everything checked into SVN has .0 as the last number, and only the CI server changes this value when it's doing a build. This lets us quickly tell the difference between developer-created builds (which are never allowed to go to customers) and "official" builds created by the CI server.