Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-17492

Update the Java version inside the Atlassian Docker images

      Summary

      Remote agents inside the Docker images are failing to start up with an "Unsupported major.minor version 52.0" error. This usually happens when we try to run a class compiled using a higher Java version (e.g. Java 8) compiler into a lower Java version (e.g. Java 7), because higher versions usually have features that are not supported by lower versions.

      It is necessary to update the Java version inside the Docker images provided by Atlassian at https://hub.docker.com/u/atlassian/.

      atlassian/bamboo-java-agent
      atlassian/bamboo-base-agent
      

      They're currently running Java 7, according to our doc. However remote agents 5.10.x will not start up with Java 6 or 7, it is necessary to have Java 8 installed, as per the Supported Platforms.

      Steps to Reproduce

      Follow the Getting started with Docker and Bamboo documentation to make use of the Docker images provided by Atlassian at https://hub.docker.com/u/atlassian/.

      Expected Results

      The remote agent starts up and is ready to build.

      Actual Results

      The remote agent fails to start up with the following error message:

      Running [/root/bamboo-agent-home/bin/bamboo-agent.sh, console]
      Agent process started, shutdown hook registered, proceeding with log pump...
      Running Bamboo Agent...
      STATUS | wrapper  | 2016/04/26 13:32:49 | --> Wrapper Started as Console
      STATUS | wrapper  | 2016/04/26 13:32:50 | Launching a JVM...
      INFO   | jvm 1    | 2016/04/26 13:32:50 | Wrapper (Version 3.2.3-atlassian-1) http://wrapper.tanukisoftware.org
      INFO   | jvm 1    | 2016/04/26 13:32:50 |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
      INFO   | jvm 1    | 2016/04/26 13:32:50 |
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,304 INFO [WrapperSimpleAppMain] [AgentBootstrap] Starting Agent Bootstrap using Java 1.7.0_65 from Oracle Corporation Default charset: US-ASCII
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,306 INFO [WrapperSimpleAppMain] [AgentBootstrap] Agent bootstrap using baseUrl: http://192.168.10.80:8086/agentServer/
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,646 INFO [WrapperSimpleAppMain] [RemoteAgentHomeLocatorForBootstrap] Using agent home located at [/root/bamboo-agent-home]
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,646 INFO [WrapperSimpleAppMain] [RemoteAgentHomeLocatorForBootstrap] Using agent home located at [/root/bamboo-agent-home]
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,647 INFO [WrapperSimpleAppMain] [AgentUuidInitializer] Generating new UUID for this agent: f461244e-5c42-4fce-8519-e16b6ddc5e8d
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,654 INFO [WrapperSimpleAppMain] [AgentContext] Requesting fingerprint, url: http://192.168.10.80:8086/agentServer/GetFingerprint.action?hostName=3dd9d657ebd1&version=3&agentUuid=f461244e-5c42-4fce-8519-e16b6ddc5e8d
      INFO   | jvm 1    | 2016/04/26 13:32:50 | 2016-04-26 13:32:50,772 WARN [WrapperSimpleAppMain] [AgentContext]
      INFO   | jvm 1    | 2016/04/26 13:32:50 |
      INFO   | jvm 1    | 2016/04/26 13:32:50 | ********************************************************************************
      INFO   | jvm 1    | 2016/04/26 13:32:50 | *
      INFO   | jvm 1    | 2016/04/26 13:32:50 | * This agent requires manual approval. Message from the server is:
      INFO   | jvm 1    | 2016/04/26 13:32:50 | * Approve this agent at 'http://webserver.bamboo/admin/agent/viewAgents.action?focusUuid=f461244e-5c42-4fce-8519-e16b6ddc5e8d&selectedTab=Agent+authentication'. Check that the IP is correct.
      INFO   | jvm 1    | 2016/04/26 13:32:50 | * Next authentication attempt in 60 seconds...
      INFO   | jvm 1    | 2016/04/26 13:32:50 | *
      INFO   | jvm 1    | 2016/04/26 13:32:50 | ********************************************************************************
      INFO   | jvm 1    | 2016/04/26 13:32:50 |
      INFO   | jvm 1    | 2016/04/26 13:33:50 | 2016-04-26 13:33:50,791 INFO [WrapperSimpleAppMain] [AgentContext] Successfully authenticated with Bamboo server at http://192.168.10.80:8086/agentServer/
      INFO   | jvm 1    | 2016/04/26 13:33:50 | 2016-04-26 13:33:50,797 INFO [WrapperSimpleAppMain] [BootstrapUpdater] Checking if bootstrap /root/bamboo-agent-home/lib/bamboo-agent-bootstrap.jar is up to date, using url: http://192.168.10.80:8086/agentServer/GetJar?name=bootstrap-with-deps&checksum=16552062&fingerprint=-7795811455529438540
      INFO   | jvm 1    | 2016/04/26 13:33:50 | 2016-04-26 13:33:50,805 INFO [WrapperSimpleAppMain] [BootstrapUpdater] New bootstrap is available, proceeding with update...
      INFO   | jvm 1    | 2016/04/26 13:33:50 | 2016-04-26 13:33:50,828 INFO [WrapperSimpleAppMain] [BootstrapUpdater] Bootstrap has been downloaded, updating file...
      INFO   | jvm 1    | 2016/04/26 13:33:50 | 2016-04-26 13:33:50,831 INFO [WrapperSimpleAppMain] [BootstrapUpdater] Bootstrap successfully updated.
      INFO   | jvm 1    | 2016/04/26 13:33:50 | 2016-04-26 13:33:50,831 INFO [WrapperSimpleAppMain] [AgentContext] Important agent classes have been updated, the agent will now terminate to pick up the latest changes.
      ERROR  | wrapper  | 2016/04/26 13:33:51 | JVM exited unexpectedly.
      STATUS | wrapper  | 2016/04/26 13:33:55 | Launching a JVM...
      INFO   | jvm 2    | 2016/04/26 13:33:55 | Wrapper (Version 3.2.3-atlassian-1) http://wrapper.tanukisoftware.org
      INFO   | jvm 2    | 2016/04/26 13:33:55 |   Copyright 1999-2006 Tanuki Software, Inc.  All Rights Reserved.
      INFO   | jvm 2    | 2016/04/26 13:33:55 |
      INFO   | jvm 2    | 2016/04/26 13:33:55 | WrapperSimpleApp: Unable to locate the class com.atlassian.bamboo.agent.bootstrap.AgentBootstrap: java.lang.UnsupportedClassVersionError: com/atlassian/bamboo/agent/bootstrap/AgentBootstrap : Unsupported major.minor version 52.0
      INFO   | jvm 2    | 2016/04/26 13:33:55 |
      INFO   | jvm 2    | 2016/04/26 13:33:55 | WrapperSimpleApp Usage:
      INFO   | jvm 2    | 2016/04/26 13:33:55 |   java org.tanukisoftware.wrapper.WrapperSimpleApp {app_class} [app_arguments]
      INFO   | jvm 2    | 2016/04/26 13:33:55 |
      INFO   | jvm 2    | 2016/04/26 13:33:55 | Where:
      INFO   | jvm 2    | 2016/04/26 13:33:55 |   app_class:      The fully qualified class name of the application to run.
      INFO   | jvm 2    | 2016/04/26 13:33:55 |   app_arguments:  The arguments that would normally be passed to the
      INFO   | jvm 2    | 2016/04/26 13:33:55 |                   application.
      STATUS | wrapper  | 2016/04/26 13:33:57 | <-- Wrapper Stopped
      Waiting for the agent process to finish...
      Underlying agent process has terminated cleanly,
      Bamboo Agent Installer is shutting down, the underlying agent process has already been shut down.
      

      Workaround

      Step 1: Customization

      To customize an image, run it in a container. Name the container for easier access later. In this example we will call it ATL:

      1. sudo docker run --name="ATL" -e HOME=/root/ -i -t atlassian/bamboo-java-agent:latest /bin/bash

        Once you run this command you'll get automatically logged in to the container.

      Step 2: Install additional Ubuntu packages

      We have to add some packages to Ubuntu so we can install Java through the command line:

      1. sudo apt-get install python-software-properties
      2. sudo apt-get update
      3. sudo apt-get install software-properties-common
      Step 3: Install Java

      In this example we will download Java 8 from the Webup8 repository. In this step you can use any repository you want to download Java 8 from. This is only one example of repository that you can use to download Java 8 from. Use this at your own risk.

      1. sudo add-apt-repository ppa:webupd8team/java
      2. sudo apt-get update
      3. sudo apt-get install oracle-java8-installer

      Now we have to set up the Java 8 environment variables:

      1. sudo apt-get install oracle-java8-set-default
      2. export JAVA_HOME=path/to/jdk/install
      3. export PATH=$JAVA_HOME/bin:$PATH
      Step 4: Building your own image

      Here you will create a new image from the container you've installed Java 8. Without closing the terminal window you're using to access the container, open a new terminal window and run:

      1. sudo docker commit ATL customized-bamboo-java-agent:1.0.0
      Step 5: Verify your custom image

      Run the following command from the terminal window to check your current docker images. You should see your customized image named customized-bamboo-java-agent in the list with TAG 1.0.0.

      1. docker images
      Step 6: Start your customized Docker image
      1. sudo docker run -e HOME=/root/ -e BAMBOO_SERVER=http://hostname:port/bamboo -i -t customized-bamboo-java-agent:1.0.0

            [BAM-17492] Update the Java version inside the Atlassian Docker images

            s2zaman added a comment -

            Successfully got the agent running inside container.

            Great resource.

            THANKS guys.

            s2zaman added a comment - Successfully got the agent running inside container. Great resource. THANKS guys.

            s2zaman added a comment -

            And a question to ask regarding both images;

            atlassian/bamboo-java-agent

            atlassian/bamboo-base-agent

            It would be great if Bamboo provide these docker-images for Windows Containers, as currently they are only available to be pulled-in to Linux Containers ?

            s2zaman added a comment - And a question to ask regarding both images; atlassian/bamboo-java-agent atlassian/bamboo-base-agent It would be great if Bamboo provide these docker-images for Windows Containers, as currently they are only available to be pulled-in to Linux Containers ?

            s2zaman added a comment -

            Encountered the very same issue.

            Following up with your provided steps.

            s2zaman added a comment - Encountered the very same issue. Following up with your provided steps.

            You can encode this behaviour into a docker image through "docker build" with the following Dockerfile:

            FROM atlassian/bamboo-java-agent:latest
            
            RUN apt-get install -y python-software-properties
            RUN apt-get update
            RUN apt-get install -y software-properties-common
            
            RUN add-apt-repository ppa:webupd8team/java
            RUN apt-get update
            RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
            RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections
            RUN apt-get install -y oracle-java8-installer
            
            RUN apt-get install -y oracle-java8-set-default
            
            CMD /root/run-agent.sh
            

            dhardiker_adaptavist added a comment - You can encode this behaviour into a docker image through "docker build" with the following Dockerfile: FROM atlassian/bamboo-java-agent:latest RUN apt-get install -y python-software-properties RUN apt-get update RUN apt-get install -y software-properties-common RUN add-apt-repository ppa:webupd8team/java RUN apt-get update RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections RUN apt-get install -y oracle-java8-installer RUN apt-get install -y oracle-java8-set-default CMD /root/run-agent.sh

            If you have security token verification turned on, this agent won't work (it needs updating) but you can fix that while you're doing step 3.

            1. cd /root
            2. wget https://bamboo.server.com/agentServer/agentInstaller/atlassian-bamboo-agent-installer-5.12.3.1.jar (the version number might be different)
            3. mv atlassian-bamboo-agent-installer-5.12.3.1.jar atlassian-bamboo-agent-installer.jar

            Carry on with the rest of the instructions. Unfortunately the run-agent.sh script will no longer work, so when you run the docker container you'll need to do something like this:

            docker run -i -t customized-bamboo-java-agent:1.1.0 java -jar /root/atlassian-bamboo-agent-installer.jar https://bamboo.server.com/agentServer/ -t 98238592358923859832598235
            

            Replace 98238592358923859832598235 with whatever you get from https://bamboo.server.com/admin/agent/addRemoteAgent.action and you should see something like this in the output:

            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] *****************************************************************************************************************************************************************
            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] *                                                                                                                                                               *
            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * Bamboo agent '1a1a1a1a1a' ready to receive builds.
            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * Remote Agent Home: /root/bamboo-agent-home
            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * Broker URL: failover:(ssl://bamboo.server.com:54663?wireFormat.maxInactivityDuration=300000)?maxReconnectAttempts=10&initialReconnectDelay=15000
            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] *                                                                                                                                                               *
            INFO   | jvm 1    | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] *****************************************************************************************************************************************************************
            

            dhardiker_adaptavist added a comment - If you have security token verification turned on, this agent won't work (it needs updating) but you can fix that while you're doing step 3. cd /root wget https://bamboo.server.com/agentServer/agentInstaller/atlassian-bamboo-agent-installer-5.12.3.1.jar (the version number might be different) mv atlassian-bamboo-agent-installer-5.12.3.1.jar atlassian-bamboo-agent-installer.jar Carry on with the rest of the instructions. Unfortunately the run-agent.sh script will no longer work, so when you run the docker container you'll need to do something like this: docker run -i -t customized-bamboo-java-agent:1.1.0 java -jar /root/atlassian-bamboo-agent-installer.jar https://bamboo.server.com/agentServer/ -t 98238592358923859832598235 Replace 98238592358923859832598235 with whatever you get from https://bamboo.server.com/admin/agent/addRemoteAgent.action and you should see something like this in the output: INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] ***************************************************************************************************************************************************************** INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * * INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * Bamboo agent '1a1a1a1a1a' ready to receive builds. INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * Remote Agent Home: /root/bamboo-agent-home INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * Broker URL: failover:(ssl://bamboo.server.com:54663?wireFormat.maxInactivityDuration=300000)?maxReconnectAttempts=10&initialReconnectDelay=15000 INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] * * INFO | jvm 1 | 2016/08/02 00:54:58 | 2016-08-02 00:54:58,294 INFO [AgentRunnerThread] [RemoteAgent] *****************************************************************************************************************************************************************

            I followed these instructions and unfortunately it seems that the docker command is stripped, so I needed to tell it to run /root/run-agent.sh in my docker command - something like this:

            docker run -e BAMBOO_SERVER=https://bamboo.server.com/ -i -t customized-bamboo-java-agent:1.0.0 /root/run-agent.sh
            
            

            dhardiker_adaptavist added a comment - I followed these instructions and unfortunately it seems that the docker command is stripped, so I needed to tell it to run /root/run-agent.sh in my docker command - something like this: docker run -e BAMBOO_SERVER=https: //bamboo.server.com/ -i -t customized-bamboo-java-agent:1.0.0 /root/run-agent.sh

            Would like to second this. Additionally it would be really nice to have some more tags on Docker Hub. Right now there is only one in addition to the latest-Branch. Unfortunately it (5.6.1) failed with the same error for me. More tags, with older versions, would have potentially alleviated this. Especially regarding a stable build process, it would be helpful to be able to fix your "local", that you're pulling from Docker Hub, version to a specific one. Would have hated for this problem to disrupt our live build chain (which was fortunately not the case). A bit more selection would help this tremendously.

            Jonas Ulrich added a comment - Would like to second this. Additionally it would be really nice to have some more tags on Docker Hub. Right now there is only one in addition to the latest-Branch. Unfortunately it (5.6.1) failed with the same error for me. More tags, with older versions, would have potentially alleviated this. Especially regarding a stable build process, it would be helpful to be able to fix your "local", that you're pulling from Docker Hub, version to a specific one. Would have hated for this problem to disrupt our live build chain (which was fortunately not the case). A bit more selection would help this tremendously.

              jmajkutewicz Jan Majkutewicz (Inactive)
              brosa Bruno Rosa
              Affected customers:
              13 This affects my team
              Watchers:
              19 Start watching this issue

                Created:
                Updated:
                Resolved: