TeamCity File Content Replacer - use variable Configuration Parameter - teamcity

Is it possible to use a $1 as a Configuration Parameter name?
Find what: <(.*)>
Replace with: %$1%

Related

How to make Gitlab CI not apply variable when the variable is in file

I have created a GitLab pipeline and predefined variable (type file). That file contains a variable ${myVar} that should not has to be applied before some steps of the job.
I found that when I open that file using cat, the ${myVar} disappeared. Looks like it was applied but with an empty string since its content has not yet been generated.
Question: how to tell GitLab CI to ignore variables in the variable file
The issue is fixed. All you need to do is to add one more $ sign before the variable. Hence instead of ${myVar} you need to specify $${myVar} in this case GitLab CI will not apply the variable
As of Gitlab 13.7 you can disable variable expansion for the variable (enabled by default). See:
https://gitlab.nposervices.com/help/ci/variables/index#expand-cicd-variables

Variable in library path with JMeter is not working

My JMeter plan config looks like this:
as you can see from the picture the mypath variable has a default value /somehwere which may change based on the machine that hosts JMeter.
So I added it as variable in the ${mypath}/bin below for Library.
However if I run a command like:
jmeter -n ... -Jmypath=/newpath/elsewhere
it is not working. Is there any way to put that path as variable?
You need to amend the variable using __P() function like:
${__P(mypath,/somepath)}
This way you will be able to override the value using -J command-line argument and if you don't provide the override value it will default to /somepath
More information:
Configuring JMeter
Apache JMeter Properties Customization Guide
Overriding Properties Via The Command Line
I answer myself as the solution required is using the parameter -Juser.classpath=some_path which avoid the need to create an external parameter for that case.

Use Gitlab CI/CD variables in YAML file

I have got a YAML configuration file in which I need to store an API key. As I do not want to commit my API Key to my Repo I figured a Gitlab CI/CD variable would be a good option. I have configured the variable in the Gitlab UI to be:
TOKEN = "123"
My .gitlab.ci.yml file contains:
image:
name: xxx
variables:
P_TOKEN: ${TOKEN}
And my YAML file has:
spec:
command: test.sh
env_vars:
- TOKEN=${P_TOKEN}
But it just sets TOKEN in the YAML file to ${P_TOKEN} instead of the contents of ${P_TOKEN}. If I echo out my variables in my CI/CD pipeline it is set correctly.
So your YAML file is actually a template for a YAML file. You'd need to run some sort of template engine on top of it to have your ${P_TOKEN} placeholder replaced.
A very simple example using sed that might suffice for your use case:
sed -i "s/\${P_TOKEN}/$TOKEN/" your_file.yaml

How to pass a parameter as an environment variable

How do you pass a parameter as an environment variable?
Step 1: Open up user bash file 'vim ~/.bash_profile', write the environment variable and save the file
export TWLIO_NUMBER=+303....
Step 2: In the application porperties file, store the variable
twlio_number=${TWLIO_NUMBER}
Step 3: Import Value in order to use it
import org.springframework.beans.factory.annotation.Value;
#Value("${twlio_number}")
private String TWILIO_NUMBER;
Also, if I hardcode the value in the application properties file, the code works.
Pass those as Java-Opts. It will work.
How to pass JVM arguments in SpringBOOT
https://www.baeldung.com/spring-boot-command-line-arguments
So I have a system variable in my spring project.
String dataSourceUrl = System.getenv(DEFAULT_CONNECTION);
I am looking for something quick to set the variable in command line.
I found this command work in mac
export DEFAULT_CONNECTION=value (value wrap in single quote to prevent the values being replaced)
You can check by env | grep DEFAULT_CONNECTION
run as usual mvn spring-boot:run

Using user defined variables in the path of a results file in JMeter

I want to write a results CSV file in JMeter which contains a variable in path of the file I write.
E.g.
C:\\Users\\User1\\test-results\\${output}.csv
But I only seem to be able to use predefined variables like ${__time(ddMMyyHHmmss)}
Is there a way to use user defined variables in the path? I have successfully done this to find input files by defining the variable in the test plan node as a User Defined Variable.
I managed to use user defined variable in the path of result file using JMeter 2.9. REPORT is a user defined variable with value REPORT. It gives me file named REPORT.csv
In JMeter 3.1(?) (or Windows?) a double slash is required in the path.
I have used the following successfully:
c:\\jmeter\\results\\${testId}\MyReport.csv
c:\\jmeter\\results\\${testId}\MyReport.csv
c:\\jmeter\\results\\${__time(yyyyMMddHHmm)}\MyReport.csv
c:\\jmeter\\results\\${__time(yyyyMMddHHmm)}.csv
${testId} is a User Defined Variable configured in the Test Plan and set to ${__time(yyyyMMddHHmm)}

Resources