Trigger Remote Jenkins Build
-
Enabled “Trigger builds remotely” in Jenkins Job Configuration.
Click on the desired job –> Configure –> Locate the “Trigger builds remotely” under “Build Triggers” Tab
Enabled the check box of “Trigger builds remotely”
Provide some Authentication Token e.g – iFBDOBhNhaxL4T9ass93HRXun2JF161Z -
Formulate the command to run using curl.
curl –user userid:API-Token http://IP OR HOST:PORT/job/JOB_NAME/build?token=Authentication_Token
eg.curl –user admin1:xxxxxx http://xxxip:8080/job/ANT-BUILD/build?token=xxxxxx -
Formulate the command to run using curl with parameters
curl –user userid:API-Token http://IP OR HOST:PORT/job/JOB_NAME/buildWithParameters?token=Authentication_Token
eg.curl –user admin1:xxxxxx http://xxxip:8080/job/ANT-BUILD/build?token=xxxxxx -
Trigger jenkins build throught Wiki Page
<!DOCTYPE html>
<html>
<body>
<table>
<tr>
<td>Select Publish Environment:</td>
<td>
<select id="azureEnv">
<option value="test">test</option>
<option value="prod">prod</option>
</select>
</td>
</tr>
<tr>
<td>Enter Release Build Version (<span style="color:red">*</span>):</td>
<td>
<input type="text" id="buildVersion" value=""> (e.g: 7.1.2.3)
</td>
</tr>
</table>
<br>
<input type=button onclick="publish()" value='Publish' >
<script>
function publish(){
var version = document.getElementById("buildVersion").value;
if (!version.match(/\S/))
{
window.alert("Please Enter Release Build Version");
return false;
} else{
var e = document.getElementById("azureEnv")
var env = e.options[e.selectedIndex].value
var URL = "https://xxxjenkinsServer/job/xxxxyourjenkinsJob/buildWithParameters?token=[your token]&Param1="+value1+"&Param2=value2&Param3=" + value3;
window.open(URL, "_blank");
}
}
</script>
</body>
</html>