Hi Mark, Indra,

If I use wildcard as a branch specifier then what would happen if there are 
multiple matches?
I would like to know this because my requirement is take each branch and 
then build each of them separately.


On Thursday, 26 January 2017 20:21:13 UTC+5:30, Indra Gunawan (ingunawa) 
wrote:

> HI Sharan,
>
>  
>
> I sent this already:
>
>  
>
>  
>
> You can’t use the simple git pipeline command if you want to be fancy
>
>  
>
> You should use the form where you can specify more options like 
> configuring Git SCM:
>
>  
>
> checkout scm: [$class: 'GitSCM', branches: [[name: '*/test*']], 
> userRemoteConfigs: [[url: 'git@hd1:testing']]]
>
>  
>
>  
>
> *From: *<jenkins...@googlegroups.com <javascript:>> on behalf of Sharan 
> Basappa <sharan....@gmail.com <javascript:>>
> *Reply-To: *"jenkins...@googlegroups.com <javascript:>" <
> jenkins...@googlegroups.com <javascript:>>
> *Date: *Thursday, January 26, 2017 at 4:03 AM
> *To: *Jenkins Users <jenkins...@googlegroups.com <javascript:>>
> *Subject: *Re: Pipeline: wildcard for branch name
>
>  
>
> Hi David,
>
>  
>
> I am new to continuous integration and Jenkins, so I need inputs to go in 
> the right direction.
>
> My requirement is that users push branches with name test_id1/test_id2 etc.
>
> I would like to build only when users have created branches with the above 
> name.
>
>  
>
> So, after seeing the responses, it looks like I have to:
>
> 1)  first checkout the repository
>
> 2)  list out the branches, 
>
> 3)  if branch name matches test* then I checkout the corresponding branch 
> and do rest of the build
>
>  
>
> I need inputs here ...
>
>
> On Wednesday, 25 January 2017 04:53:20 UTC+5:30, David Karr wrote:
>
> On Monday, January 23, 2017 at 9:37:01 AM UTC-8, Sharan Basappa wrote: 
>
> Hi,
>
>  
>
> I am trying to create pipeline script such that it only a certain branches 
> following a naming style are built.
>
> However, pipeline bails out when I use the wildcard.
>
>  
>
> The code snippet is below:
>
>  
>
> stage 'build'
>
> node {
>
> git url: 'git@hd1:testing', branch: test*
>
> sh "pwd"
>
> sh "cat simple.csh"
>
> sh "echo $PATH"
>
> sh "csh simple.csh"
>
> echo("end of pipeline")
>
> }
>
>  
>
> I see the following output from the above script:
>
>  
>
>  
>
> Started by user User
>
>  
>
> [Pipeline] stage (build)
>
>  
>
> Using the ‘stage’ step without a block argument is deprecated
>
>  
>
> Entering stage build
>
>  
>
> Proceeding
>
>  
>
> [Pipeline] node
>
>  
>
> Running on master in /var/lib/jenkins/workspace/test_build_3
>
>  
>
> [Pipeline] {
>
>  
>
> [Pipeline] }
>
>  
>
> [Pipeline] // node
>
>  
>
> [Pipeline] End of Pipeline
>
>  
>
> groovy.lang.MissingPropertyException: No such property: test for class: 
> WorkflowScript
>
>  
>
>         at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
>
>  
>
>         at 
> org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:458)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:33)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
>
>  
>
>         at WorkflowScript.run(WorkflowScript:6)
>
>  
>
>         at ___cps.transform___(Native Method)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
>
>  
>
>         at sun.reflect.GeneratedMethodAccessor725.invoke(Unknown Source)
>
>  
>
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>  
>
>         at java.lang.reflect.Method.invoke(Method.java:606)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
>
>  
>
>         at 
> com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
>
>  
>
>         at com.cloudbees.groovy.cps.Next.step(Next.java:58)
>
>  
>
>         at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
>
>  
>
>         at 
> org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:163)
>
>  
>
>         at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:328)
>
>  
>
>         at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:80)
>
>  
>
>         at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:240)
>
>  
>
>         at 
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:228)
>
>  
>
>         at 
> org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
>
>  
>
>         at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>
>  
>
>         at 
> hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
>
>  
>
>         at 
> jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
>
>  
>
>         at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>
>  
>
>         at java.util.concurrent.FutureTask.run(FutureTask.java:262)
>
>  
>
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>
>  
>
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>
>  
>
>         at java.lang.Thread.run(Thread.java:744)
>
>  
>
> Finished: FAILURE
>
>  
>
> However, when I modify the script as follows:
>
>  
>
> stage 'build'
>
>  
>
> node {
>
> git url: 'git@hd1:testing', branch: test*
>
> sh "pwd"
>
> sh "cat simple.csh"
>
> sh "echo $PATH"
>
> sh "csh simple.csh"
>
> echo("end of pipeline")
>
> }
>
>  
>
> the code executes properly and I get the following output:
>
> Started by user User
>
> [Pipeline] stage (build)
>
> Using the ‘stage’ step without a block argument is deprecated
>
> Entering stage build
>
> Proceeding
>
> [Pipeline] node
>
> Running on master in /var/lib/jenkins/workspace/test_build_3
>
> [Pipeline] {
>
> [Pipeline] git
>
>  > git rev-parse --is-inside-work-tree # timeout=10
>
> Fetching changes from the remote Git repository
>
>  > git config remote.origin.url git@hd1:testing # timeout=10
>
> Fetching upstream changes from git@hd1:testing
>
>  > git --version # timeout=10
>
>  > git fetch --tags --progress git@hd1:testing 
> +refs/heads/*:refs/remotes/origin/*
>
>  > git rev-parse refs/remotes/origin/test^{commit} # timeout=10
>
>  > git rev-parse refs/remotes/origin/origin/test^{commit} # timeout=10
>
> Checking out Revision 264dc398372cba41c026568bd764d2656ebfc511 
> (refs/remotes/origin/test)
>
>  > git config core.sparsecheckout # timeout=10
>
>  > git checkout -f 264dc398372cba41c026568bd764d2656ebfc511
>
>  > git branch -a -v --no-abbrev # timeout=10
>
>  > git branch -D test # timeout=10
>
>  > git checkout -b test 264dc398372cba41c026568bd764d2656ebfc511
>
>  > git rev-list 264dc398372cba41c026568bd764d2656ebfc511 # timeout=10
>
> [Pipeline] sh
>
> [test_build_3] Running shell script
>
> + pwd
>
> /var/lib/jenkins/workspace/test_build_3
>
> [Pipeline] sh
>
> [test_build_3] Running shell script
>
> + cat simple.csh
>
> #!/bin/csh
>
> echo "welcome to jenkins from test branch"
>
> [Pipeline] sh
>
> [test_build_3] Running shell script
>
> + echo /sbin:/usr/sbin:/bin:/usr/bin
>
> /sbin:/usr/sbin:/bin:/usr/bin
>
> [Pipeline] sh
>
> [test_build_3] Running shell script
>
> + csh simple.csh
>
> welcome to jenkins from test branch
>
> [Pipeline] echo
>
> end of pipeline
>
> [Pipeline] }
>
> [Pipeline] // node
>
> [Pipeline] End of Pipeline
>
> Finished: SUCCESS
>
>  
>
> I need some help to figure this out why it fails when I try to use 
> wildcard.
>
> Note that, I also tried different ways of specifying the test branch - 
> "test*"
>
>
> Perhaps I'm missing something, but I believe you might be missing the 
> point of the "git" pipeline step.  It's intended to take a git url, branch 
> name, and credentials and perform a clone into the workspace. It doesn't 
> make sense to try to supply a wildcard value there.
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to jenkinsci-use...@googlegroups.com <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/03968e1f-0b02-486d-85a8-a830c0b1509c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/03968e1f-0b02-486d-85a8-a830c0b1509c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/beb3ca75-1597-416c-99da-858d1880dd6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to