Unanswered question

how to set date in test result name while running in jenkins

as per the documentation i am passing this command to set the name of test result -testResultName abc-$Date{yyyy-MM-dd_HH.mm}. But the date is not coming in the test results

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

Answers

What do you have instead of the date? Do you still see the $Date.... command?

Do you use the NeoLoad plugin to run your test or just the command line option?

For the latter you may have to add a backslash prior to the date command like this: \$Date

 

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

I am passing -testResultName "abc-\$Date{hh:mm - dd MMM yyyy}" in the output it is
abc-hh:mm - dd MMM yyyy

I am not using plugin.Using only command line

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

Hi,

Any update on my above comment

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

Do I need to import any package for Date

There's no package to install. On Linux -testResultName "abc-\$Date{yyyy-MM-dd_HH.mm}" should work and on Windows -testResultName "abc-$Date{yyyy-MM-dd_HH.mm}"

Do you put your value between double quote as above? What is your exact command line?

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

My command line is sh '/opt/neoload/bin/NeoLoadCmd -project "${WORKSPACE}/<project name>.nlp" -launch "scenario1" -testResultName "abc-\$Date{yyyy-MM-dd_HH.mm}" -NTS "<url>" -NTSLogin <NTS confg> -exit -noGUI -loadGenerators "${WORKSPACE}/neoload.yaml" -nlweb -nlwebAPIURL <nl web config> -exitCodeFailIgnore'

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

No its still the same.. I am not getting the date

I was not able to reproduce that issue. Also i was not precise enough in my last comment. Have you run your command in a linux console outside of Jenkins?

When i run the same type of command on my case the test description gets the current date as expected.

Sadasivuni V.
Sadasivuni V.

Sadasivuni V.

Level
1
314 / 750
points

I am running this code in jenkins pipeline

Okay, so it looks like $Date{} is not a jenkins variable, more like when Neoload reads it in and sees this, it knows to drop a date in, but I'm guessing here. This does work though (https://support.cloudbees.com/hc/en-us/articles/226504048...).

My command works, this

def dateFormat = new SimpleDateFormat("yyyyMMddHHmm")
sh 'NeoLoadCmd ... -testResultName "Pipeline Scenario '+ dateFormat.format(new Date()) +' (build ${BUILD_NUMBER})"

generates this -testResultName Pipeline Scenario 201904100944 (build 82)