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!

Jenkins Triggering Build in BuildMaster



  • I've created a URL Triggered Build in buildmaster with no security and have tested this by calling from a browser.

    When I try via calling this from Jenkins (have tried 1) HTTP Request plugin and 2) writing a groovy script) I get an authorisation error.

    I then tried adding a username and password to the URL Triggered Build and then can no longer trigger the build from a browser.

    Any ideas why this isn't working?

    Thanks,
    Andrew

    PS Can you also point me at some documentation for passing build number as a parameter

    PPS Is it possible to trigger build promotion via url/api in similar way to triggering a build? The approach I am looking at is:

    1. Jenkins is building application and sending artifacts to artifactory
    2. Jenkins triggers build in BuildMaster and BuildMaster will deploy to the automated test environment
    3. Jenkins will run tests and if successful ask BuildMaster to deploy to the next environment
    4. All other Build promotion steps will be manual and done in BuildMaster

    Product: BuildMaster
    Version: 4.4.5



  • There was a bug that was fixed in the v4.5 line related to URL-triggered builds, ideally an upgrade to the newest version would resolve that.

    To pass a build number as a parameter, simply add buildNumber={requested-build-number} to the query string, similar to the way you would specify any additional variables.

    You could trigger a build promotion via the API, specifically the Builds_PromoteBuild method (check the /api/json page in your BuildMaster install). As an example, you can make a GET request to this URL assuming the API is enabled to promote (substituting the correct IDs):

    http://buildmaster-server/api/json/Builds_PromoteBuild?API_Key=your-api-key&Application_Id=4&Release_Number=5.0.0&Build_Number=2&ExecutionStart_Date=11/17/2014%2010:37&ForcePromotion_Indicator=N&DependencyContingent_Indicator=N&PromoteTo_Environment_Id=2
    

    If you have execution variables or promotion variables (i.e. execution variables with "Set only on initial promotion" checked), you can set those from the query string as well with:

    &Execution_Variables_Xml=<Variables><Variable Name="name" Value="value" /></Variables>
    

    and

    &Promotion_Variables_Xml=<Variables><Variable Name="name" Value="value" /></Variables>


  • I've upgraded to 4.5.2.11 and still have the same issues.

    If I set username/password then when I call this from browser I get a popup dialog asking for additional authentication details - neither my buildmaster login nor the build username/password combo get me past this.

    Without the username/password security option I can trigger a build via a browser, but unable to via Jenkins using http request plugin. I get the following response:

    Started by user SUMNER Andrew
    [EnvInject] - Loading node environment variables.
    Building remotely on JBMSAAT_WHOS796 (JBMSAAT) in workspace c:\jenkins\workspace\SmartViewer-DeployViaBuildMaster
    HttpMode: POST
    Parameters: 
      SMARTVIEWER_VERSION = 0.1.0.433
      SOURCE_BUILD_NUMBER = 433
    URL: http://buildmaster/trigger-build?id=37&Build_Number=433&SMARTVIEWER_VERSION=0.1.0.433
    Sending request to url: http://buildmaster/trigger-build?id=37&Build_Number=433&SMARTVIEWER_VERSION=0.1.0.433
    Response Code: HTTP/1.1 401 Unauthorized
    Response: 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
    <style type="text/css">
    <!--
    body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
    fieldset{padding:0 15px 10px 15px;} 
    h1{font-size:2.4em;margin:0;color:#FFF;}
    h2{font-size:1.7em;margin:0;color:#CC0000;} 
    h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
    #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
    background-color:#555555;}
    #content{margin:0 0 0 2%;position:relative;}
    .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
    -->
    </style>
    </head>
    <body>
    <div id="header"><h1>Server Error</h1></div>
    <div id="content">
     <div class="content-container"><fieldset>
      <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
      <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
     </fieldset></div>
    </div>
    </body>
    </html>
    
    Build step 'HTTP Request' marked build as failure
    [description-setter] Description set: 
    Finished: FAILURE


  • Incase there was a problem in Jenkins I've tried to to do the same using a groovy script. I get the same authorisation error. My script is below:

    /**

    */

    //@GrabResolver(name='artifactory', root='http://artifactory:8081/artifactory/repo1', m2Compatible=true)
    //@Grab('org.codehaus.groovy.modules.http-builder:http-builder:0.6')
    import groovyx.net.http.RESTClient

    def config = [
    server: 'http://buildmaster',
    apiKey: 'customs',
    applicationId: 37,
    buildNumber: '433',
    version: '0.1.0.433',
    username: 'xxxx',
    password: 'xxxx'
    ]

    def buildMaster = new BuildMaster(config)

    def resp = buildMaster.createBuild()
    println resp.data

    public class BuildMaster {
    def config

    def BuildMaster(config) {
    this.config = config
    }

    /**

    • Creates a new build of an application and optionally promotes it to the first environment.
      */
      def createBuild() {
      def path = '/api/json/Builds_CreateBuild'
      println "create build"

      def restClient = obtainServerConnection()
      def variables = '<Variables><Variable Name="SMARTVIEWER_VERSION" Value="' + config.version + '" /></Variables>'

      def resp = restClient.get(path: path, query: [API_Key: config.apiKey, Application_Id: config.applicationId, Requested_Build_Number: config.buildNumber, BuildVariables_Xml: variables])

      return resp
      }

    private RESTClient obtainServerConnection() {
    def restClient = new RESTClient(config.server)

      // By default failures throw exceptions - this stops that happening
      restClient.handler.failure = { resp, data -> resp.setData(data); return resp }
      
      //restClient.headers['Authorization'] = 'Basic ' + "$config.username:$config.password".getBytes('iso-8859-1').encodeBase64()
      
      return restClient
    

    }
    }



  • Panic over, ntlm authentication rather than basic authentication required.



Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation