Tasks broken since 5.10.0

Issue #4 resolved
Andreas Schufft created an issue

Bamboo 5.10.0 changed the method signature of

public static AgentContext RemoteAgent.getContext() from @Nullable to @NotNull. The tasks are using "RemoteAgent.getContext() != null" to detect whether they are executed on a remote agent. But this method will throw an IllegalStateException since 5.10.0 - so no more tasks could be executed. An example for this error is the following stacktrace:

error 27-Jan-2016 17:21:39 Error occurred while running Task 'copy maven-release-version(10)' of type com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:copy-variable. error 27-Jan-2016 17:21:39 java.lang.IllegalStateException: No agent context error 27-Jan-2016 17:21:39 at com.google.common.base.Preconditions.checkState(Preconditions.java:173) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.v2.build.agent.remote.RemoteAgent.getContext(RemoteAgent.java:276) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.plugins.variable.updater.task.executor.CopyVariableTask.executeTask(CopyVariableTask.java:76) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.plugins.variable.updater.task.executor.CopyVariableTask.execute(CopyVariableTask.java:27) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$120(TaskExecutorImpl.java:269) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:202) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:269) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:108) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:74) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:214) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:139) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:130) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:215) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:129) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:136) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20) error 27-Jan-2016 17:21:39 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52) error 27-Jan-2016 17:21:39 at java.lang.Thread.run(Thread.java:745) simple 27-Jan-2016 17:21:39 Running post build plugin 'NCover Results Collector'

Comments (21)

  1. Andreas Schufft reporter

    Hi Chandler,

    I downloaded the 1.1.20 from the marketplace and receive the same error. IllegalStateException when com.atlassian.bamboo.v2.build.agent.remote.RemoteAgent.getContext is called. I checked the plugin source using jd-gui (because I could not find any relevant changes here in the source code), and the tasks are calling RemoteAgent.getContext() -> but this throws and exception in bamboo 5.10.0.

    I forked the repository and created a fix which works for me:

    Output from build when using plugin version 1.20.0:

    simple  28-Jan-2016 11:33:02    Build Wieselhuber und Partner - mm-dojo Main - release-start #210 (WUNDP-MMDOJOM-REL-210) started building on agent Default Agent
    8< - - -  snip
    simple  28-Jan-2016 11:33:12    Starting task 'extract-maven-version' of type 'com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:variable-extractor'
    simple  28-Jan-2016 11:33:12    Variable wasn't found in the Build context. It possibly doesn't exist. 
    error   28-Jan-2016 11:33:12    Error occurred while running Task 'extract-maven-version(5)' of type com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:variable-extractor.
    error   28-Jan-2016 11:33:12    java.lang.IllegalStateException: No agent context
    error   28-Jan-2016 11:33:12        at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.v2.build.agent.remote.RemoteAgent.getContext(RemoteAgent.java:276)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.plugins.variable.updater.task.executor.ExtractVersionVariableTask.executeTask(ExtractVersionVariableTask.java:66)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.plugins.variable.updater.task.executor.VersionVariableTask.execute(VersionVariableTask.java:33)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$120(TaskExecutorImpl.java:269)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:202)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:269)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:108)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:74)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:214)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:139)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:130)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:215)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:129)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:136)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)
    error   28-Jan-2016 11:33:12        at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)
    error   28-Jan-2016 11:33:12        at java.lang.Thread.run(Thread.java:745)
    simple  28-Jan-2016 11:33:12    Running post build plugin 'NCover Results Collector'
    

    After this I set the version for the forked plugin to 1.1.21-SNAPSHOT and uploaded this plugin to the bamboo instance and rerun the incomplete build step:

    simple  28-Jan-2016 11:54:21    Build Wieselhuber und Partner - mm-dojo Main - release-start #210 (WUNDP-MMDOJOM-REL-210) started building on agent Default Agent
    8< - - - snip
    simple  28-Jan-2016 11:54:32    Starting task 'extract-maven-version' of type 'com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:variable-extractor'
    simple  28-Jan-2016 11:54:32    Variable wasn't found in the Build context. It possibly doesn't exist. 
    simple  28-Jan-2016 11:54:32    Changing variable maven.pom.version of type RESULT from null to 1.0.72
    simple  28-Jan-2016 11:54:32    Finished task 'extract-maven-version' with result: Success
    simple  28-Jan-2016 11:54:32    Starting task 'save-release-version' of type 'com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:copy-variable'
    simple  28-Jan-2016 11:54:32    Changing variable maven.release.version of type RESULT from  to 1.0.72
    simple  28-Jan-2016 11:54:32    Finished task 'save-release-version' with result: Success
    simple  28-Jan-2016 11:54:32    Starting task 'prepare-development-version' of type 'com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:copy-variable'
    simple  28-Jan-2016 11:54:32    Changing variable maven.development.version of type RESULT from  to 1.0.72
    simple  28-Jan-2016 11:54:32    Finished task 'prepare-development-version' with result: Success
    simple  28-Jan-2016 11:54:32    Starting task 'compute-next-devlopment-number' of type 'com.atlassian.bamboo.plugins.variable.updater.variable-updater-generic:variable-updater'
    simple  28-Jan-2016 11:54:32    Changing variable maven.development.version of type RESULT from 1.0.72 to 1.0.73
    simple  28-Jan-2016 11:54:32    Finished task 'compute-next-devlopment-number' with result: Success
    

    What I've found is that the RemoteAgent.getContext() method which is called in the tasks (to determine whether the build is running on a remote agent) throws an exception when running on a local agent. I just made a dirty fix by adding

       boolean isRemote() {
          try {
             return (RemoteAgent.getContext() != null);
          } catch (IllegalStateException e) {
             return false;
          }
       }
    

    and replaced the (RemoteAgent.getContext() != null) in ReadFileVariableTask, ExtractVersionVariableTask, CopyVariableTask, AdvanceVersionVariableTask by a call to isRemote().

    The plugin version 1.1.20 does not work for me (and I think it will not run on any Bamboo 5.10.0)....

  2. Andreas Schufft reporter

    FYI - I just synced this repo to the fork and it shows only 1 change in the master branch:

    version tag in pom.xml changed from 1.1.20-SNAPSHOTto 1.1.21-SNAPSHOT... Possibly an error during merge?

  3. Chandler Zhang

    I thought your issue was caused by the bamboo whitelist feature, so I made a new release which contained the fix. Actually both 1.1.19 and 1.1.20 contained the fix.

    FYI - I just synced this repo to the fork and it shows only 1 change in the master branch:

    I think it is because we only bump version when making a new release.(There's a merge since 1.1.19 before I released 1.1.20)

  4. Andreas Schufft reporter

    Hi Chandler,

    in the current binary (1.0.20 from marketplace) and here in the source view, I can see the failing code is not removed. I sent you an invitation to the fork - feel free to review, merge or pick up some of the changes. I currently run with my manually build SNAPSHOT version of this task - so for me it's not urgent, but possibly for other users.

  5. Sopheon IT

    If you can update the add-on as soon as possible, that would be great! We are waiting on the fix for 5.10.1.1. Thanks.

  6. Chandler Zhang

    @aschufft @SophInfra I have released the fix to marketplace, close this issue. Feel free to reopen it if you still have problems

  7. Sopheon IT

    I downloaded the jar file and installed it. I will have our developers run a build and see if it fixes the problems. It looks like the Bamboo version detection is not set right, as it thinks that version 1.1.20 is newer than 1.1.21. It is also listed in the wrong order on the marketplace versions page.

  8. Chandler Zhang

    It looks like the Bamboo version detection is not set right, as it thinks that version 1.1.20 is newer than 1.1.21

    It is because our pipeline was broken when releasing 1.1.20 and I manually released it with wrong build number, sorry for that.

  9. Andreas Schufft reporter

    Hi Chandler,

    I just installed 1.1.21 and the issue is fixed. I will delete the fork during the next days, because it's no longer required. Thank you again for your help.

  10. Brendon Thiede

    My instance still wants to grab 1.1.20 as the latest. Was that thought to be resolved, or in the future going to be resolved?

  11. Stephen Sugden

    Hi. I'm in the process of evaluating Bamboo (5.10.0) and have just installed this plugin from the market place. The plugin version reported is 1.1.20 and I'm experiencing the original issue (IllegalStateException). Any news on when version 1.1.21 will be available via the market place?

    Update - I was able to find and install version 1.1.21 manually - it's listed under "other versions" here. Thanks

  12. Chandler Zhang

    @SteveSugden @brendonthiede As I said before, 1.1.21 is on marketplace but since I manually uploaded 1.1.20 and used the wrong build number, upm thought 1.1.20 was the latest release. I'll do another release with nothing change but a new version number to get rid of the confusion. Sorry for that.

  13. Nilesh Prasad

    Hi Chandler,

    I am getting the same error with Bamboo version 5.13.0.1 using plugin version 1.1.20.

    03-Nov-2016 09:13:26    java.lang.IllegalStateException: No agent context
    03-Nov-2016 09:13:26            at com.google.common.base.Preconditions.checkState(Preconditions.java:173)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.v2.build.agent.remote.RemoteAgent.getContext(RemoteAgent.java:276)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.plugins.variable.updater.task.executor.AdvanceVersionVariableTask.executeTask(AdvanceVersionVariableTask.java:69)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.plugins.variable.updater.task.executor.VersionVariableTask.execute(VersionVariableTask.java:33)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$200(TaskExecutorImpl.java:313)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:246)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:313)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:118)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:74)
    03-Nov-2016 09:13:26            at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:215)
    

    If I install plugin version 1.1.21, bamboo complains that it is incompatible with my version of bamboo.

    Could you please advice if the fix is in 1.1.20? Aslo if 1.1.21 should be compatible with bambo version 5.13.0.1?

    I installed the plugins using bamboo's 'Find new add-ons' feature.

    Cheers, Nilesh.

  14. JOSEPH ALLEN

    I am also running 5.13.2 and 1.1.20, still having this issue. I don't see the option in the plugin manager to update to a newer version.

    Edit* I just manually downloaded 1.1.21 plugin and forced the install. It complains that I don't have the latest version, and that it is not compatible with my version of Bamboo...but it works.

  15. adisor19 Account Deactivated

    I'm running 5.13.2 as well and I forced installed 1.1.21 but it did not fix the problem and it complained the plugin was not compatible. Worse yet, I can no longer access the Addons section. My browser just times out.

    Is this normal ?

  16. Log in to comment