How to pass the additional parameter of slash command to jenkins job - jenkins

Let's say I want to create a slash command with the flexibility to define the component as tag name which will be used for deployment.
eg: /dev-deploy comments v1.0.0
I have added the slash command as well as set the parameterized URL in
http://host/buildByToken/buildWithParameters?job=dev-deployment&token=test
All the other commands data is present in JSON object how can I access that data and pass it as a parameter to shell script which is executed when the build is triggered.

The slash command from Slack is sending a POST request to your URL. This request contains a property named text, which in your example would be "comments v1.0.0". To extract the tag you would need to parse it.
I would recommend to use some simple script (e.g. PHP) to receive the POST request, parse it (maybe also do some security checks) and then start the job with a shell command.
I am not sure what JSON object you are referring to. The slash command does not send any JSON. So maybe your question is missing some vital information? If so please add.
Here is an example of the POST request (from the official Slack documentation):
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
enterprise_id=E0001
enterprise_name=Globular%20Construct%20Inc
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678

Related

JMeter: How can I capture the variable value which is dynamic in url?

We have a URL https://www.mylink.com/est?myId=4d22b9d0-4ff2-46c3-9343-945304dfea93
The above request also contains post data:
myId=4d22b9d0-4ff2-46c3-9343-945304dfea93
How can I parameterize this as the url and post data both contain same value but its dynamic. Also, how may I store it in a variable to use it somewhere else as well?
In order to be able to use it in URL and request body you need to extract it somewhere somehow, this dynamic ID is probably associated with this or that user account so my expectation is that after logging in you should see this ID somewhere in the response.
The process is known as correlation and there is a plenty of information over the web about handling dynamic requests in JMeter. There are also solutions which provide semi or fully automated correlation of the dynamic parameters like Correlations Recorder Plugin for JMeter or JMeter Proxy Recorder
If you just need to generate an unique GUID-like structure - you can do it using __UUID() function

Slack slash commands - Variable/Parameters

I'm integrating slack with jenkins to use slash commands and want to know if slash commands have variables
What I want to do is something like this;
/this_word_should_be_in_the_url word
and the be able to use word in the URL the slash command will call.
On their page they have something like /weather 94070
Do I have access to the 94070 and somehow set is as a query parameter for the URL.
Is this possible?
Can't find any documentation of this.
Thanks.
Yes. You will have access to the word as per the example that you mentioned.
So for example, if you have the following:
/this_word_should_be_in_the_url word
Then there will be an additional query parameter named text that will contain everything else after the slash command. If you just have one parameter then it should be simple to just trim and use the text query parameter but if you have multiple words and need to split them into something more meaningful, then you might have to use some regex or simple string split function.
It is documented at How do commands work. In this section they have provided the various query parameters that will get passed to your Slash Command External URL. For the weather example, the data posted as per the documentation is:
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678
Notice the text parameter in the above list.

Can I use # in a Slack slash command?

I am creating a custom slash command that hooks up to a RESTful API. I am looking to send a user id of the current users choosing, so I'd love to be able to use the # shortcut to bring up the list of teammates. This API call is expecting a user id and a message. Is something like this possible:
/SLASHCOMMAND #USER, MESSAGE
You can certainly type #whatever into a a slash command, but the text will just be sent as-is to your HTTP endpoint.
In the example above, you would receive "#USER, MESSAGE" as the text of the slash command. (If you want an ID, you'll then have to do your own parsing to find at-mentions and use the Slack Web API to figure out the ID corresponding to that username.)

get GET request in Golang on fcgi

I run my scripts under Apache. I understand how I can create request, for example:
http.Get(url)
How I can get GET request? I really dont see this information in docs. Thanks in advance!
UPD
For example, i do GET or POST-request to my go script from another script. In PHP I'd just write $a=$_GET["param"]. How i can do that in Go? Sorry for bad english, by the way
Your handler is passed a Request. In that Request you find for example the parameters in the Form field as soon as you parsed it using ParseForm :
// Form contains the parsed form data, including both the URL
// field's query parameters and the POST or PUT form data.
// This field is only available after ParseForm is called.
// The HTTP client ignores Form and uses Body instead.
Form url.Values

Jmeter - URL changes when the recorded scripts are run

Please me here as we are newbie to JMeter.
We are performing a Load Test on a module called Reports.
The recorded script (URL) changes during run-time. Following is the example.
Original recorded script (URL):
https://dev.test.com/reportserver/Pages/ReportViewer.aspx?%2FArrowAddOnReport%2FClientsPending&AgencyName=ArrowSeed
URL generated during run-time:
https://dev.test.com/reportserver/Pages/ReportViewer.aspx?%2FArrowAddOnReport%2FClientsPending=&AgencyName=ArrowSeed
If you can see, "=" is added in the URL (highlighted).
Please let us know the reason and resolution to handle the same.
Thanks in advance
I have no idea why it happens, you should talk to DevOPS or whoever is responsible.
Personally I wouldn't use "Path" section to store request parameters, there is a "Parameters" section in the HTTP Request where you can specify required parameters and whether to encode them or not.
If you're completely stuck with an extra = sign I can suggest a workaround.
Add a Beanshell Pre Processor as a child of the problematic HTTP Request
Put following code into Beanshell Pre Processor "Script" area:
String path = sampler.getPath();
sampler.setPath(path.replace("=&","&"));

Resources