I have been trying to set a environment variable property for DB connection parameters via a fitnesse suite setup page.
I have tested this by setting the environment variable on an individual test page, and when I do this it does get resolved in my fixture API. But when I remove it from the test page and include it in the fitnesse setup page, it can't be resolved in my fixture API for some reason.
This is the COMMAND_PATTERN string I have included to add the environment property:
!define COMMAND_PATTERN {java -cp %p -Ddbadapter.config=classpath:/properties/fiAdapter-config.properties %m}
So this very string is correctly resolved when defined on a test page, but I move it out to the setup test page (which I know is successfully passing down other page level params to the tests), its not resolvable in my fixture API.
I have also tried specifying this property on startup of the fitnesse server:
java -jar -Dadapter.config=classpath:/properties/fiAdapter-config.properties fitnesse.jar -p 6538
and this doesn't isnt working for me either. The only way I can get this working is by specifying the parameter on each test page and that is defeating the purpose of using a properties file for this.
Any idea on what is causing this would be appreciated!
Variables are set by looking through direct ancestry, rather than through siblings or even SetUp pages. I generally define them either in the environment before running FitNesse or through the FrontPage or the Suite page that contains the tests that need it.
As far as I know, SetUp processes as a part of the page. And I can see why you chose that, but I don't think it is as reliable a location for defining variables as a direct ancestor page.
Additionally, if you are using the COMMAND_PATTERN variable, I'm pretty sure you have to define the variable you want to send to it before you change the COMMAND_PATTERN. And the command pattern cannot be changed multiple times in a single suite execution.
Related
Since I have the same static rarely changed parameters used by several jobs I decided to put it somewhere in one place of my Jenkins and use it across jobs.
The first thought that came to my mind was to move my 'static data' to the environment variables and get it using Active choice reactive parameter plugin which allows running simple groovy scripts on the job parameters page.
Please note that I know how to get environment parameters in the pipeline, but I do really need to have this data on the build with parameters screen, e.g. once I clicked build with parameters - I need my groovy code inside Active choice reactive parameter was able to read this environment variable and display as a parameter to the user.
A simple example of this need:
The environment variable contains the list of servers, the job is going to perform deployment of the application to the selected server. In this case, I want to be able to write something like this in the groovy script section of Active choice reactive parameter:
return[${env.SERVERS_LIST}]
Unfortunately the example above doesn't work. I wasn't able to find any working solution for this yet.
Well, after a few more tries I finally found a solution.
Instead of trying to read the environment variable in the pipeline manner the simple
return [SERVERS_LIST]
works perfect
I'm writing a TFS / VSTS integration with our server by using extension.
I want to present extra data after the build, specifically I want to show an IFRAME and navigate to our server, to a specific URL, determined in part by a dynamically generated unique string.
I have the function that generates the string, but I need to set it as an environment variable before the tests start to run. This is important because the tests need to create that string on the server.
I searched the documentation, examples and other places, but couldn't find a complete example that sets a dynamically generated environment variable and then runs tests.
How do I do it?
You can add/set an environment variable through Logging Commands (e.g. PS: Write-Host "##vso[task.setvariable variable=testvar;]testvalue"), then the following tasks can get this variable as general variable.
With Logging Commands, you also can add additional information in build summary. (##vso[task.uploadsummary]local file path)
You also can deploy a build result extension to display additional information. vsts-extension-samples
Is there a way to overwrite a value contained within a config.properties file via Jenkins?
I have the following config.properties file contained within my automation framework:
browser=chrome
url=http//www.example.com
If the value of chrome get changed to firefox then all tests will now execute within firefox browser.
I can manually change this value by directly accessing the config.properties file but can the value get altered via jenkins?
I use the Pipeline Utility Steps plugin to read properties files, and it looks like it can write a few other types of files, but not properties files.
It seems to me that you want to make this change in this file so you can run some tests first in one browser, then in another. If this is the case, I think a better way to handle this is to try to get your tests to point to different files. This is a little cleaner, and allows things like parallel execution and when you find that another thing needs to change in the future, you won't be writing so many things to the file in a script, which gets a little error prone.
If you can't make your tests execute against a different properties file, you could have a copy of each file you need, and then copy them to them appropriate filename to execute your tests.
But maybe I made poor assumptions as to your setup here. ;)
Yes.
You can create a build parameter as $browser to accept the value say "firefox" and using sed inside "execute shell", replace the value in config.properties.
Once done, execute your scripts.
This is just overview as you have not posted details about your config.properties file, its location, if you are using Jenkins jobs or jenkinsfile/pipeline etc.
I'm trying to use global variables within Jenkins on Windows to "automagically" retrieve the proper code base from our SCM system, but in each case that I've tried the variable substitution is not happening.
I've set up some global variables, with default values, within "Configure System" and have tried to access them with $VARIABLE, ${VARIABLE} and %VARIABLE% as part of the Branch field for the Surround SCM plugin with no success whatsoever.
I've also installed the Global Variable String Parameter plugin with the same success rate (0%). Using a literal value works just fine, but no type of variable substitution seems to work at all and I'm sure that someone has come upon this before and resolved it.
I've tried searching for something similar to this but nothing really approaches this usage of globals, instead it is normally discussed as a function within an external script, or parameter passed to a batch file, etc.
I've run "set" as the first step and can see that the variable is available, but the substitution is just not happening. If it means I will have to script something, then so be it, as I am trying to make this extremely flexible and as headache free as possible, but that isn't seeming to be the case in this case thus far.
My problem is eerily similar to this post: How are environment variables used in Jenkins with Windows Batch Command?, but again, I'm not looking to script this as it is a MUCH simpler solution to use the variable values directly.
from https://wiki.jenkins-ci.org/display/JENKINS/Surround+SCM+Plugin
Troubleshooting
Please contact Seapine support with questions about the integration or
to report bugs or feature requests.
Set your Jenkins project to be parameterized. Create a string parameter GIT_BRANCH that will be your branch variable (for example).
Under Source Control Management, use your branch variable in the form $GIT_BRANCH
That’s it. When you run your project, you will be prompted to enter a value for your GIT_BRANCH parameter.
I am trying to send a variable to my grails app through the command line similar to this:
grails -Dmy.build.number=33 prod war ROOT.war
I have tried to access it as grailsApplication.config.my.build.number but I get an empty map. It seems odd that the variable is defined but not set to what I send.
How do I access the command-line property?
I am planning on putting some of my assets(css,js,images,etc) in cloudfront to act as a cdn. So in my build phase I want to use the build number as a cache buster and set my assets to point to mycloudfronturl/assets/${buildnumber}/script.js. If there is a better approach, I'm open to that as well.
System.getProperty("my.build.number");