Specifying build parameters to FAKE - f#-fake

I am essentially asking for an update to date answer to the already answered question: Can I pass a parameter to a F# FAKE build script?
Here is build.fsx
let revisionNumber = getBuildParamOrDefault "rev" "123"
Target "Log" (fun _ ->
trace ("Revision Number: " + revisionNumber)
)
RunTargetOrDefault "Log"
Output running Fake.exe .\build.fsx:
Perfect!
Output running Fake.exe .\build.fsx rev=456 (as suggested by this answer: https://stackoverflow.com/a/26597179/2382536):
Starts with
But at the bottom gives the correct result:
What format do I need to pass the parameters in to get rid of the warning message?

Passing parameters is done using the --envvar parameter. Until recently you can just add parameters in a way you did after the build target but not anymore. I believe this was changed in order not to confuse build parameters with (optional) build target name.
So, try this:
fake build.fsx Push --envvar rev 456

I just want to share the link to the official documentation:
TLDR:
You can either use
--envvar [-ev] <name:string> <value:string>
to set a variable to a custom value, or
--envflag [-ef] <name:string>
to set a variable to true, or
--fsiargs --debug+ buildscript.fsx someArg1 anotherArg2
to pass all arguments (including build script name, importent!) direcly to fsi.exe

Related

How to get a particular value when using karate.fork?

When we use karate.fork for CLI command and need some information from there to be stored in a variable and using it in the next step.
for EX - karate.fork('java -version')
We need to get only the version data alone.
Then karate.fork() is the wrong choice - just use karate.exec() instead. It does the same thing, but will block, and also return the console output:
* def output = karate.exec('java -version')
Please read this also for advanced examples: https://stackoverflow.com/a/62911366/143475

Issues pulling change log using python

I am trying to query and pull changelog details using python.
The below code returns the list of issues in the project.
issued = jira.search_issues('project= proj_a', maxResults=5)
for issue in issued:
print(issue)
I am trying to pass values obtained in the issue above
issues = jira.issue(issue,expand='changelog')
changelog = issues.changelog
projects = jira.project(project)
I get the below error on trying the above:
JIRAError: JiraError HTTP 404 url: https://abc.atlassian.net/rest/api/2/issue/issue?expand=changelog
text: Issue does not exist or you do not have permission to see it.
Could anyone advise as to where am I going wrong or what permissions do I need.
Please note, if I pass a specific issue_id in the above code it works just fine but I am trying to pass a list of issue_id
You can already receive all the changelog data in the search_issues() method so you don't have to get the changelog by iterating over each issue and making another API call for each issue. Check out the code below for examples on how to work with the changelog.
issues = jira.search_issues('project= proj_a', maxResults=5, expand='changelog')
for issue in issues:
print(f"Changes from issue: {issue.key} {issue.fields.summary}")
print(f"Number of Changelog entries found: {issue.changelog.total}") # number of changelog entries (careful, each entry can have multiple field changes)
for history in issue.changelog.histories:
print(f"Author: {history.author}") # person who did the change
print(f"Timestamp: {history.created}") # when did the change happen?
print("\nListing all items that changed:")
for item in history.items:
print(f"Field name: {item.field}") # field to which the change happened
print(f"Changed to: {item.toString}") # new value, item.to might be better in some cases depending on your needs.
print(f"Changed from: {item.fromString}") # old value, item.from might be better in some cases depending on your needs.
print()
print()
Just to explain what you did wrong before when iterating over each issue: you have to use the issue.key, not the issue-resource itself. When you simply pass the issue, it won't be handled correctly as a parameter in jira.issue(). Instead, pass issue.key:
for issue in issues:
print(issue.key)
myIssue = jira.issue(issue.key, expand='changelog')

Using result from the first request and passing in the second request- POSTMAN

I want to use the result which is "id" and use it in the second request POST
Saving it as environmental variable in the first request(under tests)
var jsonData = JSON.parse(responseBody);
postman.setEnvironmentVariable("id", jsonData.token);
Here is the second request looks like, not sure what I am doing wrong here
Your request is correct.
As long as you set an environment variable, you may USE this environment. From your print screen I see "no environment" on the top right corner.
I suggest either you create an environment where to save your environment variables and then use it or you use a global variable, postman.setGlobalVariable("id", ...) instead
Alex

BeanShell PreProcessor updates User define variables

I'm very new at JMeter issues.
In a test script i have a BeanShell PreProcessor element that updates some variables previously defined at a "User Defined Variables" element.
Latter those variables are used in "Http Requests". However, the value that is used in the http request is the default one.
The scripts seems to be working due to some debug print();
My question is if it's necessary to delay the script to be sure that the BeanShell finishes?
Thanks a lot for your attention
There is no need to put any delay to Beanshell Pre-Processor as it's being executed before request. I'd recommend to check your jmeter.log file to see if there are any scripting issues as Beanshell Pre-Processor does not report errors anywhere including View Results Tree listener.
There are at least 2 ways to assure that everything is fine with your Beanshell script:
Put your debug print code after variables replace logic to see if it fires
Use JMeter __Beahshell function right in your HTTP request. If it's ok - View Results Tree will demonstrate beanshell-generated value. If not - the field will be blank and relevant error will be displayed in the log.
Example test case:
Given following Test Plan structure:
Thread Group with 1 user and 1 loop
HTTP GET Request to google.com with path of / and parameter q
If you provide as parameter "q" following beanshell function:
${__BeanShell(System.currentTimeMillis())}
and look into View Results Tree "Request" tab you should see something like:
GET http://www.google.com/?q=1385206045832
and if you change function to something incorrect like:
${__BeanShell(Something.incorrect())}
you'll see a blank request.
The correct way of changing existing variable (or creating new if variable doesn't exist) looks like
vars.put("variablename", "variablevalue");
*Important: * JMeter Variables are Java Strings, if you're trying to set something else (date, integer, whatever) to JMeter Variable you need to cast it to String somehow.
Example:
int i = 5;
vars.put("int_i", String.valueOf(i));
Hope this helps.
You can update the vale of a "user defined variable".
You have to create a bean shell sampler
vars.put("user_defined_variable", "newvalue");
#theINtoy got it right.
http://www.blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell
I'm new to jmeter too but as I know variables defined in "User defined variables" are constants, so you can't change them. I recommend to use "User Parameters" in preprocessors or CSV Data Set Config.

Reference a variable within a variable in JMeter

I'm working with JMeter. I'd like to specify the test host using user defined variables, like this:
variable name value
localhost localhost
test 192.168.0.1
hostname ${localhost}
Executing the test, I see that the hostname value is not substituted, and obviously the test fails. I know I can use properties and pass the hostname from the command line, or simply change the hostname value. Is it possible to it like I've explained?
Thanks.
I've managed to solve my problem. I've changed the hostname variable value to: ${__evalVar(${localhost})}, but I've got this error:
ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined
So I've moved the hostname variable declaration in a "User defined variable" child node of my Sampler node. That solved it.
To solve this you should use hostname = ${__eval(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__eval
Carlos' answer has a mistake (which I can't comment on due to rep) as it uses evalVar, this requires as an argument a plain string:
This works: ${__evalVar(localhost)})
This works: ${__eval(${localhost})}
This doesn't work (the current answer): ${__evalVar(${localhost})}
http://jmeter.apache.org/usermanual/functions.html#__evalVar
Check this forum:
from Blazemeter
For example: getting value of varible "listid_XXX" where the XXX number comes from an index variable:
${__V(listid_${idx1})}
New newer versions (from 2.2), you can use ${__V(${...})}/.
Ex: ${__V(${SERVER_CONTEXT})}/rest
As #Alies Belik mentioned, if you get
ERRROR jmeter.functions.EvalVarFunction: Variables have not yet been defined
then define the 2nd variable in next other UDV (User Defined Variables) node.