3

I have to integrate jbehave with jenkins. But I don't have idea how to do this. I saw that I have to create a task in Jenkins, but I don't know where I should wire jbehave with this task.

Can somebody help me?

Thanks,

Sarang

3
  • 1
    How do you run JBehave from the command line? Just take that and add to a Jenkins job as an "Execute shell" or batch command. Aug 15, 2012 at 15:55
  • No. I have a POM file and I think that I have to put something there to achieve running the automated test cases. What do you think? Aug 15, 2012 at 20:08
  • Figure out how to run that POM from the command line (e.g. mvn compile test) and either use an "Execute shell" step (in the Freestyle job type), or create a Maven job type and add "compile test" as the goals. Aug 16, 2012 at 9:12

3 Answers 3

5

So I'm assuming you have JBehave integrated with Maven, correct? The simple build environment can be set up as follows:

  1. Go to Jenkins and add a new job of type "Build a maven2/3 project"
  2. Configure your project to check out your from whatever source repository you use.
  3. Configure the build phase of the project to run whatever Maven goal you need ("install" will probably work)
  4. Hit save and you have a working project that will execute exactly as it would from a command line.

If you want to see the JBehave test output rendered nicely in Jenkins you should also follow these instructions to configure the Jenkins/XUnit plugin: http://jbehave.org/reference/stable/hudson-plugin.html

You will also need to make sure your project is configured to use the XML Output format in your StoryReporterBuilder to make use of the plugin (not mentioned in the instructions above).

1
  • 1
    I have Jbehave integrated with Maven and I have three execution tags inside of the plugin whose artifactId is <artifactId>jbehave-maven-plugin</artifactId>. The goal of the first execution is run-stories-as-embeddables, then the second is map-stories-as-embeddables and finally report-stepdocs-as-embeddables. This pom was taken from the etsy.com project which is located on JBehave website like example. That works perfect. Now, How can I setup which stories will be run through Jenkins? and not overriden the method storyPaths? Are you getting me? Oct 15, 2012 at 14:31
1

You can visit the following for details:

http://jbehave.org/reference/stable/hudson-plugin.html

1
  • Those instructions are perfect, although typically it is a standard to include the relevant points here in your answer. Thanks.
    – djangofan
    Jul 22, 2013 at 16:27
0

Per your comments, you want to specify the stories to run via Jenkins when using the Maven plugin. Here is one way:

Create a subclass of StoryFinder and set it as the storyFinderClass property in your Maven configuration. In the Jenkins commandline launcher, you can pass in stories as a -D system property which can then be read from your StoryFinder.

Commandline

mvn ... -Dcom.sarang.stories="foo.story,bar.story"

Maven

<plugin>
    <groupId>org.jbehave</groupId>
    <artifactId>jbehave-maven-plugin</artifactId>
    <version>[version]</version>
    <executions>
        <execution>
            <id>run-stories-as-embeddables</id>
            <phase>integration-test</phase>
            <configuration>
                ...
                <systemProperties>
                    <property>
                      <name>com.sarang.stories</name>
                      <value>${com.sarang.stories}</value>
                    </property>
                </systemProperties>
                <storyFinderClass>com.sarang.MyStoryFinder</storyFinderClass>
            </configuration>
            <goals>
                <goal>run-stories-as-embeddables</goal>
                ...
            </goals>
        </execution>
    </executions>
</plugin>

StoryFinder

package com.sarang;

import org.jbehave.core.io.StoryFinder;
import java.util.*;

public class MyStoryFinder extends StoryFinder {
    @Override
    protected List<String> scan(String basedir, List<String> includes,
            List<String> excludes) {
        //List<String> defaultStories = super.scan(basedir, includes, excludes);
        String myStories = System.getProperty("com.sarang.stories");
        return Arrays.asList(myStories.split(","));
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.