Use Jenkins Variable as Feeder

Hello everyone
I am using gatling 3.4.1

In my test I need to use a header in base64 ( ex : Authorization" → “Basic ${token}” )
In order not to be accessible by everyone in the repository, I use it as a jenkins variable.

I pass that parameters from the command line to the Simulation with JAVA_OPTS

then in my simulation

val token = System.getProperty(“Basictoken”)

val scn = scenario(“test”)
feed(token)
.exec(…

However I get an error when I want to pass it to Feed :

overloaded method value feed with alternatives:
(feeder: io.gatling.core.feeder.Feeder[Any])io.gatling.core.structure.ChainBuilder
(feederBuilder: io.gatling.core.feeder.FeederBuilder)io.gatling.core.structure.ChainBuilder
cannot be applied to (String)

Any ideas ?

Thank you in advance

Here, your basic token seems a single string.

Try putting your variable directly in your header.
https://gatling.io/docs/current/http/http_request/#headers

http("Custom headers")
  .post("myUrl")
  // Adds your token
  .header("Authorization", s"Basic $token")

Mind the classic scala string interpolator s"…"

As your variable token does not come from session.

Hello

Thanks for your reply .
I already tried this way but i get the error :

not found: value token

To be more specific my scenario is like this :

val token = System.getProperty(“Basictoken”)

val httpProtocol = http
.baseUrl(“http://…”)

val scn = scenario(“test”)
.repeat(10)
{
feed(somefeed)

.exec(object1.Def1())

.exec(object1.Def2 ())


}

setUp(
scn.inject(
atOnceUsers(1)
).protocols(httpProtocol))

So this specific needed headers with $token is call in one of this Def, not all , but it can’t find it even using : .header(“Authorization”, s"Basic $token")

Regads

First, are you sure the token value is well filled? (try printlin it)

The error “not found: value token” seems like what you get when it is an EL and gatling tried to get from session. (without the s in front of the string), it is feasible to add it to the session but it is not the point I discuss here.

Def1 is a function (if I believe the parentheses pair after), you can give token as an argument to it, and in your Def1 add the header.

As in the documentation, you can prepare the headers

class MySimulation extends Simulation {
val authorizationHeaders = Map(“Authorization” → s"Basic $token")
println(authorizationHeaders)

val scn = scenario(“test”)
.repeat(10) {
feed(somefeed)

.exec(object1.Def1(authorizationHeaders))

.exec(object1.Def2())

}

object object1 {
def Def1(headersArg: Map[String, String]) =
http(“My special request”)
.post(“myUrl”)
.headers(headersArg)
}