Any reason for not using jenkins notifyCommit[0] API ?.If we trigger
using build trigger API then in the build log the cause of the build
will not be a commit,It will be displayed as triggered by admin.

[0]curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git
repository>

On Fri, Oct 18, 2013 at 9:27 AM,  <[email protected]> wrote:
> Author: [email protected]
> Date: Fri Oct 18 09:27:13 2013
> New Revision: 188652
> URL: http://wso2.org/svn/browse/wso2?view=rev&revision=188652
>
> Log:
> auto build when a git push
>
> Modified:
>    
> scratch/appfactorycc/products/appfactory/1.1.0/vmware/appfactory_deployment/resources/configs/jenkins.groovy
>
> Modified: 
> scratch/appfactorycc/products/appfactory/1.1.0/vmware/appfactory_deployment/resources/configs/jenkins.groovy
> URL: 
> http://wso2.org/svn/browse/wso2/scratch/appfactorycc/products/appfactory/1.1.0/vmware/appfactory_deployment/resources/configs/jenkins.groovy?rev=188652&r1=188651&r2=188652&view=diff
> ==============================================================================
> --- 
> scratch/appfactorycc/products/appfactory/1.1.0/vmware/appfactory_deployment/resources/configs/jenkins.groovy
>         (original)
> +++ 
> scratch/appfactorycc/products/appfactory/1.1.0/vmware/appfactory_deployment/resources/configs/jenkins.groovy
>         Fri Oct 18 09:27:13 2013
> @@ -68,10 +68,12 @@
>  // gitblit.properties or web.xml
>  def tmpArr = repository.name.split("/")
>  def domainName = tmpArr[0]
> -//logger.info("domainName:" + domainName)
> +logger.info("******************" + tmpArr[1])
> +def tmpAppNameArr = tmpArr[1].split(".git")
> +def appName = tmpAppNameArr[0]
> +logger.info("domainName:" + domainName)
>  def s = new HashSet()
>  def jenkinsUrl = 
> gitblit.getString('groovy.jenkinsServer'+'/t/'+domainName+'/webapps/jenkins', 
> 'https://jenkins.milestones.appfactory.wso2.com:9674/t/'+domainName+'/webapps/jenkins')
> -//logger.info("************************"+jenkinsUrl)
>
>  for (command in commands) {
>  logger.info("************************"+command)
> @@ -109,12 +111,21 @@
>
>  // define the trigger url
>  for(branch in s){
> -//logger.info("************************inside branch in s")
> -def triggerUrl = jenkinsUrl + 
> "/git/notifyCommit?url=$url/git/$repository.name"+"&branches="+branch
> -//logger.info("************************value of triggerUrl "+ triggerUrl)
> -def response = "curl -k -X POST ${triggerUrl}".execute().text
> -println response
> +       if(s.contains('master')){
> +               s = 'trunk'
> +       }
> +//with this curl command the build will trigger as the jenkins admin using 
> the admin's API Token
> +//def curlCommand = "curl  -k -X POST 
> https://jenkinssystemadmin:ca01a7927702b67ec66f5560da6ce...@jenkins.milestones.appfactory.wso2.com:9674/t/manipiya11.com/webapps/jenkins/job/app1-trunk-default/buildWithParameters?token=build&[email protected]&isAutomatic=false&persistArtifact=true&doDeploy=true&deployAction=deploy&deployStage=Development";
> +
> +       //with this curl command, the build will not trigger because of an 
> authenticated user is not specified
> +       def curlCommand = "curl  -k -X POST  
> https://jenkins.milestones.appfactory.wso2.com:9674/t/${domainName}/webapps/jenkins/job/${appName}-${s}-default/buildWithParameters?token=build&tenantUserName=${user.username}&isAutomatic=false&persistArtifact=true&doDeploy=true&deployAction=deploy&deployStage=Development";
> +
> +//def curlCommand = "curl  -k -X POST 
> https://jenkinssystemadmin:ca01a7927702b67ec66f5560da6ce...@jenkins.milestones.appfactory.wso2.com:9674/t/manipiya11.com/webapps/jenkins/job/app1-trunk-default/buildWithParameters?token=build&[email protected]&isAutomatic=false&persistArtifact=true&doDeploy=true&deployAction=deploy&deployStage=Development";
> +
> +       logger.info("Executing curl command :" + curlCommand)
>
> +       def response = curlCommand.execute().text
> +       println response
>  }
>
>  // do BAM publishing
> _______________________________________________
> Commits mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/commits



-- 
ajanthan
-- 
Ajanthan Balachandiran
Senior Software Engineer;
Solutions Technologies Team ;WSO2, Inc.;  http://wso2.com/

email: [email protected]; cell: +94775581497
blog: http://bkayts.blogspot.com/

Lean . Enterprise . Middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to