Integration of jbehave with jenkins

2019-05-14 22:42发布

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条回答
神经病院院长
2楼-- · 2019-05-14 22:55

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(","));
    }
}
查看更多
我只想做你的唯一
3楼-- · 2019-05-14 23:01

You can visit the following for details:

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

查看更多
聊天终结者
4楼-- · 2019-05-14 23:12

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).

查看更多
登录 后发表回答