Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Trigger Job multiple times in quick succession leaves job pending

    Scheduled Pinned Locked Moved Support
    buildmaster
    3 Posts 1 Posters 11 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ? This user is from outside of this forum
      Guest
      last edited by

      I've written a java unit test (below) to simulate calling the API to trigger a build several times in quick succession (The job has a build step which calls a powershell script and sleeps for 1 minute). To test the Jenkins plugin that I have developed.

      If I trigger and waite for the Job to finish then all is well. If I run in a loop 3 times in succession the previous 2 builds are marked as "Build rejected due to creation of new build." but the remaining one has a status of pending andwith the message "This execution is scheduled to to occur in the future."

      I wouldn't have thought this behaviour is what you would have expected to get. Is there a bug here?

      Test Code

      @Test
      public void queueBuilds() throws IOException {
      	String releaseNumber = buildmaster.getLatestActiveReleaseNumber(MockServer.APPLICATION_ID);
      	
      	Map<String, String> variablesList = new HashMap<>();
      	
      	for (int i = 1; i < 4; i++) {
      		System.out.println("Build: " + String.valueOf(i));
      		String prevBuildNumber = buildmaster.getPreviousBuildNumber(MockServer.APPLICATION_ID, releaseNumber);
      		System.out.println("\tPreviousBuildNumber=" + prevBuildNumber);
      					
      		variablesList.put("hello", "world" + String.valueOf(i));			
      		String buildNumber = buildmaster.createBuild(MockServer.APPLICATION_ID, releaseNumber, variablesList);
      		System.out.println("\tBuildNumber=" + buildNumber);
      		
      		Variable[] variables = buildmaster.getVariableValues(MockServer.APPLICATION_ID, releaseNumber, buildNumber);
      		String value = "not found";
      		
      		for (Variable variable : variables) {
      			if (variable.Variable_Name.equalsIgnoreCase("hello")) {
      				value = variable.Value_Text;
      			}
      		}
      		
      		System.out.println("\tVariable HELLO=" + buildNumber);
      	}
      }
      

      Log

      Build: 1
      [BuildMaster] Executing request http://buildmaster/api/json/Builds_GetBuilds?API_Key=customs&Application_Id=36&Release_Number=1.3&Build_Count=
      PreviousBuildNumber=81
      [BuildMaster] Executing request http://buildmaster/api/json/Builds_CreateBuild?API_Key=customs&Application_Id=36&Release_Number=1.3&BuildVariables_Xml=<Variables><Variable Name="hello" Value="world1" /></Variables>
      BuildNumber=82
      [BuildMaster] Executing request http://buildmaster/api/json/Variables_GetVariableValues?API_Key=customs&Application_Id=36&Release_Number=1.3&Build_Number=82
      Variable HELLO=82
      
      Build: 2
      [BuildMaster] Executing request http://buildmaster/api/json/Builds_GetBuilds?API_Key=customs&Application_Id=36&Release_Number=1.3&Build_Count=1
      PreviousBuildNumber=82
      [BuildMaster] Executing request http://buildmaster/api/json/Builds_CreateBuild?API_Key=customs&Application_Id=36&Release_Number=1.3&BuildVariables_Xml=<Variables><Variable Name="hello" Value="world2" /></Variables>
      BuildNumber=83
      [BuildMaster] Executing request http://buildmaster/api/json/Variables_GetVariableValues?API_Key=customs&Application_Id=36&Release_Number=1.3&Build_Number=83
      Variable HELLO=83
      
      Build: 3
      [BuildMaster] Executing request http://buildmaster/api/json/Builds_GetBuilds?API_Key=customs&Application_Id=36&Release_Number=1.3&Build_Count=1
      PreviousBuildNumber=83
      [BuildMaster] Executing request http://buildmaster/api/json/Builds_CreateBuild?API_Key=customs&Application_Id=36&Release_Number=1.3&BuildVariables_Xml=<Variables><Variable Name="hello" Value="world3" /></Variables>
      BuildNumber=84
      [BuildMaster] Executing request http://buildmaster/api/json/Variables_GetVariableValues?API_Key=customs&Application_Id=36&Release_Number=1.3&Build_Number=84
      Variable HELLO=84
      

      Product: BuildMaster
      Version: 4.6.3

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        I have a work around in place - I don't call the createbuild api until the build step has completed. Be nice not to have to worry about it though...

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          If "Multiple Active Builds" is enabled for the application, the builds will queue (i.e. the latest ones will stay "Pending" until the prior ones finish sequentially). Without that setting, newer builds will reject older builds for the same release.

          Beyond that, your workaround for the non-mulitple-active builds setting will work fine.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post
          Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation