I want to run the Maven release programmatically from a Java program. This web page shows how this is done in general. So what I did:
final URL url = new URL("http://jenkins/job/MyProject/m2release/submit"); final HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setRequestMethod("POST"); urlConnection.setDoOutput(true); final String userpass = "User:Password"; final String authentication = "Basic " + DatatypeConverter.printBase64Binary(userpass.getBytes()); urlConnection.setRequestProperty("Authorization", authentication); try (final OutputStream os = urlConnection.getOutputStream(); final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));) { writer.write("releaseVersion=1.2.3&"); writer.write("developmentVersion=1.2.4-SNAPSHOT&");
This forum offers "just take a look at the form before release and you can process the cURL request", which I did with go this far. The release starts at least.
I just donβt understand how to avoid everything. The browser shows spaces as "+", but it does not work if I send data this way. In fact, neither "", "+", nor "% 20" work like space.
However, I get Unable to commit files in the assembly, so I'm sure something is wrong with the username / password / comment prefix. Jenkins himself returns the login page ("Authentication Required"), even though the login is being sent.
What is the correct way to run Maven Release on Jenkins?
jenkins
Steffi S.
source share