Recently I have started working on CI project, It has to build the project on SCM commit (Git/SVN). I tried using Build trigger remotely and it is triggering the Job when I commit the code and building the application successfully.
Now I have multiple projects in a single repository, So based on my commit it has to find the respective project in the repository and start executing the specific job.
Is there any way to do this in Jenkins?
Code for post-commit-hook-jenkins.vbs file
Set args = WScript.Arguments
JobName = args.Item(0)
Token = args.Item(1)
' URL to open
sUrl = "http://builduser:a844e9e505bfc5e6e9ce6e953ba5443a@localhost:8080/buildByToken/build?job=" + JobName + "&token=" + Token
' POST Request to send.
WScript.Echo "sUrl: " + sUrl
sRequest = ""
HTTPPost sUrl, sRequest
Function HTTPPost(sUrl, sRequest)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", sUrl,false
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.send sRequest
HTTPPost = oHTTP.responseText
End Function
Code for Post-commit.bat file
SET CSCRIPT=%windir%\system32\cscript.exe
SET VBSCRIPT=E:\Repositories\CICD\hooks\post-commit-hook-jenkins.vbs
"%CSCRIPT%" "%VBSCRIPT%" "JobName" "AuthenticationToken"