# How to specify an executor parameter for the Gradle orb?

**URL:** <https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794>\
**Category:** Build Environment\
**Tags:** gradle, cimg\
**Created:** [April 17, 2023, 1:07pm UTC](https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794 "2023-04-17T13:07:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric-creekside](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/eric-creekside/32/32795_2.png) [@eric-creekside](https://discuss.circleci.com/u/eric-creekside)\
**Post date:** [April 17, 2023, 1:07pm UTC](https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794/1 "2023-04-17T13:07:16Z")

</div>

I’m trying to use the circleci/gradle@3.0.0 orb, but I need to execute builds using Java 17 (instead of the default, which seems to be Java 13). According to the orb docs, the default executor has a parameter, `tag` that can be used to specify the tag of the `cimg/openjdk` Docker image that will be used, but I can’t figure out how to specify that tag parameter in my workflow.

Here’s what I’ve tried:

```auto
version: 2.1

orbs:
  gradle: circleci/gradle@3.0.0
workflows:
  build--app1:
    jobs:
      - gradle/run:
          app_src_directory: 'App1'
          executor:
            name: default
            tag: "17.0.6"

```

That produces an error in the config editor: `Cannot find a definition for executor named default`. If I leave off the name then I get the error: `The value of name must be a string`.

So how can I specify the `tag` to be used for the executor of this orb? In general, it would be useful to have examples of “interesting” usage of the org.

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [April 18, 2023, 1:48pm UTC](https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794/2 "2023-04-18T13:48:58Z")

</div>

> [@eric-creekside](#):
>
> circleci/gradle@3.0.0

I think the issue is that the docs for the orb are ‘as clear as mud’ when it comes to how to use an executor.

From looking at the code published for the orb, what it is expecting you to do is define an executor under ‘executors:’ and then pass the name of the defined executor to the orb. ‘tag’ then becomes a parameter passed to the defined executor.

As such the following may work

```auto
version: 2.1

orbs:
  gradle: circleci/gradle@3.0.0
workflows:
  build--app1:
    jobs:
      - gradle/run:
          app_src_directory: 'App1'
          executor: default
            tag: "17.0.6"

```

As the value ‘default’ is now assigned to the parameter executor as within the orb code there is a ‘default’ executor defined called ‘default’ that accepts a parameter called tag.

---

<div class="post-metadata">

**Author:** ![eric-creekside](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/eric-creekside/32/32795_2.png) [@eric-creekside](https://discuss.circleci.com/u/eric-creekside)\
**Post date:** [April 18, 2023, 3:07pm UTC](https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794/3 "2023-04-18T15:07:53Z")

</div>

> [@rit1010](#):
>
> ```auto
> - gradle/run:
> app_src_directory: 'App1'
> executor: default
> tag: "17.0.6"
> 
> ```

Unfortunately, that didn’t work either. That’s a YAML parsing error: `mapping values are not allowed here`.

---

<div class="post-metadata">

**Author:** ![rit1010](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/rit1010/32/34738_2.png) [@rit1010](https://discuss.circleci.com/u/rit1010)\
**Post date:** [April 18, 2023, 4:55pm UTC](https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794/4 "2023-04-18T16:55:58Z")

</div>

I’ve been trying a few options, but I’ve not had any luck getting exactly the right syntax to allow the tag parameter to be passed via the orb to the executor.

What you can do is just define your own executor with its own default value for the tag and just have the orb use that.

```auto
version: 2.1

orbs:
  gradle: circleci/gradle@3.0.0

executors:
  test-exec:
    parameters:
      tag-value:
        type: string
        default: "17.0"
    docker:
      - image: cimg/openjdk:<<parameters.tag-value>>

workflows:
  build--app1:
    jobs:
      - gradle/run:
          app_src_directory: 'App1'
          executor: 
            name: "test-exec"

```

Maybe someone will be a long who does know the correct way to pass the value via the orb at some point

---

<div class="post-metadata">

**Author:** ![adamhunter](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/adamhunter/32/35434_2.png) [@adamhunter](https://discuss.circleci.com/u/adamhunter)\
**Post date:** [July 23, 2024, 2:34pm UTC](https://discuss.circleci.com/t/how-to-specify-an-executor-parameter-for-the-gradle-orb/47794/5 "2024-07-23T14:34:32Z")

</div>

I believe I got this working using the following config:

```auto
workflows:
  test:
    jobs:
    - gradle/test:
        executor:
          name: gradle/default
          tag: "21.0"

```
