问题
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
回答1:
So I'm assuming you have JBehave integrated with Maven, correct? The simple build environment can be set up as follows:
- Go to Jenkins and add a new job of type "Build a maven2/3 project"
- Configure your project to check out your from whatever source repository you use.
- Configure the build phase of the project to run whatever Maven goal you need ("install" will probably work)
- 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).
回答2:
You can visit the following for details:
http://jbehave.org/reference/stable/hudson-plugin.html
回答3:
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(","));
}
}
来源:https://stackoverflow.com/questions/11972696/integration-of-jbehave-with-jenkins