/** * Returns the HTTP POST request ready to be sent to the Stash build API for the given build and * change set. * * @param stashBuildNotificationEntity a entity containing the parameters for Stash * @param commitSha1 the SHA1 of the commit that was built * @return the HTTP POST request to the Stash build API */ private HttpPost createRequest( final HttpEntity stashBuildNotificationEntity, final String commitSha1) { String url = stashServerBaseUrl; String username = stashUserName; String pwd = Secret.toString(stashUserPassword); DescriptorImpl descriptor = getDescriptor(); if ("".equals(url) || url == null) url = descriptor.getStashRootUrl(); if ("".equals(username) || username == null) username = descriptor.getStashUser(); if ("".equals(pwd) || pwd == null) pwd = descriptor.getStashPassword().getPlainText(); HttpPost req = new HttpPost(url + "/rest/build-status/1.0/commits/" + commitSha1); req.addHeader( BasicScheme.authenticate(new UsernamePasswordCredentials(username, pwd), "UTF-8", false)); req.addHeader("Content-type", "application/json"); req.setEntity(stashBuildNotificationEntity); return req; }