How to get value of Configuration parameter in teamcity using Gradle? - gradle

I have been trying to get the value of configuration parameter since yesterday but no luck. On the documentation I can call it using this teamcity["<property name>"] but it wont work.
Say I have a configuration parameter called "isPaid". I want to get the "isPaid" param value in my gradle. How can I do that? Shouldn't that be
System.getProperty("teamcity[isPaid]")
Tried using both getProperty and getEnv but still did not work. Any ideas? Thanks

Configuration parameters (no prefix) are not passed into the build and are only meant to share settings within a build configuration.
https://www.jetbrains.com/help/teamcity/configuring-build-parameters.html

Related

Where to put credentials in gradle

Where can I put my credentials in gradle without making them public?
I would like to know some best pratics, and to understand well the difference between inserting them in gradle.properties or as environment variable.
It's important to me know how call them in build script, too.
Thanks in advance
You can put credentials in local.properties if you want to have it locally. You can retrieve them like this:
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def local = properties.getProperty('localVar')
and having local variable in local.properties:
localVar=helloWorld
The best practice would be putting it in an environment variable, in this way, you are able to run your gradle scripts anywhere even in a CI environment.
In build.gradle you can get environment variables by using
System.getenv("ENVIRONMENT_VARIABLE")

How to set variable and its value in Jmeter container like User Parameters using script

I need to set and get variables in Jmeter for API automation.
I am using the groovy script for same.
I am able to store key-values in Property Files using below code:
props.put("shubhamKey", "shubhamValue")
I do not want to use the main property as it contains so many other keys which may use by Jmeter and we can't place any hardcode key in property directly.
But I am not an able set similar thing in any of below containers :
User Defined Variables
User Parameters
The code I am trying is as below:
vars.put("shubhamUserKeyagain","shubhamUservalue")
Use vars.put and execute the script and click on User Defined Variables. The new key should reflect there but it's not. That is my main issue
I have tried to place User Parameters just below in TestPlan, With-in the request where JSR223 Assertion is present, also tried to place it before and after JSR223 Assertion
My get value is working fine from these containers but the set is not reflecting over the containers. Below code, I am using to get the value
vars.get("shubhamLocalVariable")
Another code I have tried :
vars.putAll("myNormalValue","changeho")
Is there any other container in which I can set and get key-values using the script as groovy.
Environment :
OS : Window 10
Jmeter Version: 3.2 r1790748
Running bat file as an administrator
I have added my project in below URL:
https://ufile.io/7r6tk
Please refer and let me know if I missed anything
Reference Screenshots:
User Parameter
JSR233 Assertion
This one works for me - I have cleared up your script

See parameters that are overridden from TeamCity template

Is there a way to see TeamCity configurations that override parameter defined in template?
I don't think so. What's worked for me in the past was to search through the project files on the filesystem. If you have many build configs, this will be faster than opening each of them in the GUI.
Search for something like this:
<param name="myParamInheritedFromTemplate" value="myOverrideValue" />
in <TeamCity data directory>/config/projects/**/*.xml. If it's absent in an XML file, that build config just inherits the value. If it's present, it overrides it.
It's hacky but it's quick.
There is a feature request https://youtrack.jetbrains.com/issue/TW-21212, please vote. Current workaround are to either search the raw XML files with the settings stored under TeamCity Data Directory on the server as #sferencik suggested, or use REST API to get settings of all the build configurations and search for the parameter there. Let me know if you need help on any of these.

Team City 7.1 Configuration Parameters across Build Configurations

I would like to define a variable on a TC configuration and would like to get its value on a different TC configuration that has a trigger dependency on the first one.
Is it possible to do this?
If both configurations are in the same project, you can define a build configuration template that contains the shared parameter (i.e. variable). Both active configurations must then reference that template -- use the 'Associate with Template' action to accomplish this. The value of the shared parameter must be set in the template in order for the same value to be known to both configurations.
If you're trying to share build numbers (or other system-level parameters) between the configurations, there is a special method for that.
I have to use something like this to actually dynamically change the configuration parameters.
Invoke-WebRequest -Uri "http://build/guestAuth/action.html?add2Queue=bt876&name=env&value=test&name=env.number&value=%target.env.number%" -Method "Get" -Verbose

VS2010, MSDeploy and declaration of parameters

I'm trying to deploy an ASP.NET MVC 2 app using MsDeploy. I use VS2010 to generate the package as a ZIP. Inside that ZIP is a parameters.xml file that declares the parameters that I can set.
I want to be able to set more parameters, using the auto-generated deploy.cmd file like this:
MySite.deploy.cmd
"-setParam:name='IIS Web Application Name',value=MySite"
"-setParam:name=IisVirtualDirectoryPhysicalPath,value=C:\inetpub\MySite"
"-setParam:name=httpBinding,value=*:80:www.mysite.dk"
That works fine, except for the httpBinding param. That is because that parameter is not declared inside the parameters.xml file that is added to the ZIP container.
I could go and add that parameter declaration manually, but isn't there a way to do it from the command line and have it declare parameters I have in another XML file?
Are you saying that the value param was not declared when the package was created? If so then I think you would have to add it. Either manually or you can use the -setParam switch and sync the package from and to itself. If you use -setParam with a name which was never declared as a param to begin with I'm pretty sure that value is just ignored.
I'm only just looking at this, but is the section on MSDN about the matching of declareParam with setParam the way to go ?
I'm using MsDeploy to update my deployment zip following the idea in this stackoverflow post
Apologies if I'm completely off on this

Resources