The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How i can set Java version for agent if Default job - shell script.

Igor Komarov
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 17, 2022

Hello! I use shell script for running sbt task on different environments but by default Bamboo agent uses Java8 instead Java11. How i should setUp JAVA_HOME variable or may be i have other way if we have both Java versions on Bamboo? 

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

0 votes
Anonymous Coward
Contributor
September 9, 2022

Simon says:

` Please use the Command task instead of the Script task because it allows you to set the environment for the command you are executing as well as choose the command. See the details here: https://confluence.atlassian.com/bamboo/custom-command-executable-289277045.html

Obviously if you have more things being called in your current Script task like:

#!/bin/bash

<some native bash statements>
<the sbt call that needs Java 11>
<some more native bash statements>

then you can structure your Job tasks as follows:

1. Script task 1 containing the first bash statements,

2. Command task to call the sbt task with Java 11(set the Executable parameter to the absolute path of your Java 11 java binary, the Argument parameter to what you want the JVM to run,and the Environment variables to the ones you need)

3. Script task 2 containing the rest of the bash statements in the example above.

`

I hope this helps. Simon out.

TAGS
AUG Leaders

Atlassian Community Events