Jenkins job failure when running a freestyle maven

2020-02-16 01:26发布

I have created a gatling maven based application; wrote some actions, scenario and able to successfully run them locally in IDE using $mvn gatling:test to build project and view the gatling reports.

Now I'm trying to have a jenkins job configured to automate this however using the same command in bash script is failing with :

Build step 'Execute shell' marked build as failure
Archiving Gatling reports...
Could not find a Gatling report in results folder.

My pom.xml is same as :https://github.com/gatling/gatling-maven-plugin-demo/blob/master/pom.xml except i also tried to add:

<configuration>
 <resultsFolder>/jenkinsworkspace/projectName/target/gatling</resultsFolder>
</configuration>

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>io.gatling</groupId>
  <artifactId>project-id</artifactId>
  <version>3.1.2</version>

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <gatling.version>${project.version}</gatling.version>
    <gatling-plugin.version>3.0.1</gatling-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.gatling.highcharts</groupId>
      <artifactId>gatling-charts-highcharts</artifactId>
      <version>${gatling.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>io.gatling</groupId>
        <artifactId>gatling-maven-plugin</artifactId>
        <version>${gatling-plugin.version}</version>
      </plugin>
    </plugins>
  </build>

</project>

Firstly, Do I need to use a Maven jenkins project type instead of a freestyle project?

Secondly, from testing in local my gatling reports are generated in target folder in the project structure on every execution. And in my repo I have ignored this folder (in .gitignore) so is that the reason of not being able to find in workspace when ran the job?

Not sure if its something wrong with either the maven command I'm using in execute shell Build step or is my pom.xml wrong.

From jenkins console output, it seems to download all the maven dependencies mentioned in pom.xml but then results in build failure. I'm new to this, kindly provide any suggestions and help.

2条回答
Animai°情兽
2楼-- · 2020-02-16 01:58

Created a new free style job in jenkins and configured the Build step as: put the Root POM as pom.xml , in Goals and options gatling:test

Also enabled simulation tracking

查看更多
不美不萌又怎样
3楼-- · 2020-02-16 01:59

I'm not sure how this can be fixed on a freestyle project but I'm sure a Gatling-Maven project works with a pipeline job. See a detailed description here: how to integrate gatling with jenkins

As for the reports, you have to install the Gatling plugin on Jenkins. This adds a Gatling option to the menu bar on the left where the reports are listed from all the previous builds. It also shows some build statistics on graphs, which is nice. However, the reports are not portable (or at least I didn't find a way to download and zip all the source files as I would with the local report folder).

查看更多
登录 后发表回答