I have created a parameter in Team city that is system parameter as shown below
system.version and its value is gla so it is like
system.version=gla
now can you please advise in Team City how can I configure this variable such as i want date time stamp to be appended since this variable is need to be changed every time when my build runs so I want to add the dates time stamp to this system variable please advise how to achieve this in team city.
You can add an initial build step that writes out a service message to update the parameter value (example below in PowerShell):
Step 1
$date = Get-Date
Write-Host "##teamcity[setParameter name='system.version' value='gla$date']"
Step x
Write-Host '%system.version%' # will output the new value
You can write a custom build step that calls a shell command and appends date/time to your variable
#!/bin/bash
date_var=`date +%Y%M` --> Define your format here
echo "##teamcity[setParameter name='system.version' value='$date_var']"
PS: you can use the new value of your variable only from the next build step
Related
I am using Octopus for getting my environment ready with all prerequisites. In one of the octopus step I want some varaibles values to be set dynamically for which I have used the octopus output variables.
If I want to declare the output variable in form of an array, its value not getting read in other step where I want to read that.
Below are few code snippets which I have used (Note : both the steps are having inline powershell script code written):
/*Step A code : Set output variable of step code*/
$market= "RO" /*Dynamically identify market depends on machine name */
write-host $market
Set-OctopusVariable -name "TestResult_Domain_['+%market%+']" -value
"DomainNameOfMachine"
/*Another step code*/
$market= "RO" /*Dynamically identify market depends on machine name */
write-host $market
$filterDomain = "Octopus.Action[StepA].Output.TestResult_Domain_['$market']"
I have a TeamCity build that passes some arguments to an .exe and runs it daily. One argument is for a date parameter, currently set to a static date. It now needs to be dynamic, passing in the current date.
I tried setting the value to %env.BUILD_START_DATE% but this makes all my agents incompatible because of an implicit requirement for that env variable. I also tried setting the date in the DOS command line script, skipping TC params altogether, but it still ends up with that implicit requirement.
The top answer here: TeamCity Current Date variable in MMdd format
indicated need for a TC plugin, the second answer, however, did not require a plugin and is mostly complete. How I made it work on a variation of that second answer:
1.) Add a powershell build step to run the following:
echo "##teamcity[setParameter name='env.BUILD_START_DATE' value='$([DateTime]::Now)']"
2.) Give env.BUILD_START_DATE a default value in the Environment Variables section. Without the default value TC thinks having this value is an implicit requirement of a build agent, rendering all of them incompatible.
If you are unfamiliar with PowerShell, here is a Bash approach.
You can set a parameter with script and retrieve the value from the next build step.
echo "##teamcity[setParameter name='env.BUILD_START_DATE' value='$(date +%%Y-%%m-%%dT%%H:%%M:%%S%%z)']"
The doubled %% is because TeamCity considers % as its own parameter in build script.
The parameter will have ISO8601 format timestamp. For other formats, please see various Bash date format at here; https://www.tutorialkart.com/bash-shell-scripting/bash-date-format-options-examples/
You can set the variable in the config, which should be overridden during runtime. I don't see env.BUILD_START_DATE in my TC parameters, but I do see system.buildStartTime. I set it to a dummy value (I use "[Filled Automatically]"), and everything works fine. Build gets run and system.buildStartTime gets overridden at build time.
Is there a way to access Jmeter variable data even after tests are run?
This is what i am looking for:
Run a test, store the data in a variable (test finishes in 2 mins)
Idle for 15 mins
Run another test
i want the variable in step 3, Without running step1 again.
The most straightforward choice is saving the variable(s) you need into JMeter's .jtl results file using Sample Variables property. In order to "tell" JMeter to save certain variable value you need to add the next line to user.properties file:
sample_variables=your_variable_name
Alternatively you can pass this property value using -J command-line argument
jmeter -Jsample_variables=your_variable_name -n -t ....
Once done you should see an extra column in the .jtl results file holding your variable values. You should be able to access these values using i.e. CSV Data Set Config.
See Configuring JMeter user manual chapter for more details.
Variables are per test. You need to use a resource as file.
Use propert file to save and load variable as follows:
Start jmeter with property file as -q my.properties
On your test check if property exists if exists skip step 1
If not - do step 1 and then add the variable to property file line as propName=propValue
See example
I am trying to assign value to built-in release notes variable in "Run a Script" step.
$OctopusParameters["Octopus.Release.Notes"] = "Some release notes"
In the next step "Send an Email" I am using this variable in email body, but unfortunately it is empty.
<p>#{Octopus.Release.Notes}</p>
Is it possible to set Octopus Deploy system variable value from PowerShell and use it in the next step?
I am using Octopus Deploy 3.7.11.
EDIT:
I have also tried the cmdlet Set-OctopusVariable and it did not work.
Set-OctopusVariable -name "Octopus.Release.Notes" -value "Something"
I don't think it is possible to overwrite values of the built-in variables provided by Octopus Deploy. But you could define your own output variable and refer to that in the following steps. For example in your 'Run a script'-step use:
Set-OctopusVariable -name "MyReleaseNote" -value "Some text here"
Then the "Send an Email"-step can refer to this text by using the following (assuming the first step is called 'FirstStep'):
#{Octopus.Action[FirstStep].Output.MyReleaseNote}
The variable can also be used from a script in other steps, then use the syntax:
$relnote = $OctopusParameters["Octopus.Action[FirstStep].Output.MyReleaseNote"]
(If you want to save the generated releasenote perhaps you could save it as an 'artifact' in the project).
I tried this using Octoposh. Modifying an existing variable is covered in the Octoposh wiki at Modifying Variables - Edit a variable of a Project/Library variable set.
I wasn't able to get this to work because of timeouts on our network, but it looks like it should work - just not as straight-forward as I expected.
The Xcode archive step creates this variable: ${BITRISE_DEPLOY_DIR} and read that pilot uses the PILOT_IPA environment variables for the IPA directory.
Is there a way to assign the output (BITRISE_DEPLOY_DIR) to another environment variable (e.g.: $PILOT_IPA)?
You can do that by using envman (https://github.com/bitrise-io/envman) which is part of the bitrise CLI tool stack.
To assign the value of an existing Environment Variable (Step outputs are just regular Environment Variables) you can use a Script step, and specify this as the content:
#!/bin/bash
echo "BITRISE_DEPLOY_DIR: $BITRISE_DEPLOY_DIR"
envman add --key PILOT_IPA --value "$BITRISE_DEPLOY_DIR"
This'll first print the value of the BITRISE_DEPLOY_DIR environment variable, and then with envman add it'll add a new environment item with the key PILOT_IPA and the value of $BITRISE_DEPLOY_DIR.