You may find it easier to start with a freestyle job so that you can work through the steps with a little more help from the Jenkins web interface. A freestyle job will let you define the branch with a wild card and will let you see your build results, see the summary of test results, etc. That will give you a single job which switches from one branch to another. I find results from that type of job more difficult to read because it mixes different branches into the history of the same job.
Once you have a freestyle job working, then you can move to a pipeline job, and use the "Pipeline Syntax" link on the web interface to select "checkout". In that page, you'll make the same selections as you made in the freestyle job definition, including placing the branch name you want as a wild card. That will give you a single pipeline which will switch between the branches as branches are created or as commits are added to those branches. I find results from that type of job more difficult to read because it mixes different branches into the history of the same job. Once you have a working pipeline job, then you can move to a multi-branch pipeline job, using the pipeline definition from the pipeline job. The multi-branch pipeline job will automatically define a job for each branch that matches your branch name wildcard, and can run that job when commits are detected on that branch. Results will be presented with a job per branch, so users will see the results on their branch, without intermixing changes from other branches in the job history. If you're a docker user, you can see examples of each of those types of jobs in the lts-with-plugins branch of my Jenkins docker definition ( https://github.com/MarkEWaite/docker/tree/lts-with-plugins) . Mark Waite On Thu, Jan 26, 2017 at 5:03 AM Sharan Basappa <sharan.basa...@gmail.com> wrote: > 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-users+unsubscr...@googlegroups.com. > 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/CAO49JtE9ric6615htsh%2BNgSiTi%3DV5-LS8xr0DQYStiTZR8OJ1A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.