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



  • 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



  • 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...



  • 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.


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation