詹金斯(Jenkins

发布于 2025-01-24 07:28:14 字数 6666 浏览 3 评论 0原文

Jenkins忽略了属性,不会创建诱人的重点。请帮忙。

pom.xml

<groupId>org.example</groupId>
<artifactId>GoogleTest</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <aspectj.version>1.8.10</aspectj.version>
    <allure.version>2.17.3</allure.version>
    <cucumber.version>7.2.3</cucumber.version>
</properties>

<dependencies>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>${cucumber.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>compile</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>4.4.1</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.reload4j</groupId>
        <artifactId>reload4j</artifactId>
        <version>1.2.19</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.5</version>
    </dependency>

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-testng</artifactId>
        <version>2.17.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-java-commons</artifactId>
        <version>2.17.3</version>
        <scope>compile</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-commandline -->
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-commandline</artifactId>
        <version>2.17.3</version>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-cucumber3-jvm</artifactId>
        <version>2.17.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.2</version>
        <scope>test</scope>
    </dependency>

</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>

                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.10.0</version>
            <configuration>
                <reportVersion>${allure.version}</reportVersion>
                <allureDownloadUrl>https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${allure.version}/allure-commandline-${allure.version}.zip</allureDownloadUrl>
                <reportVersion>${allure.version}</reportVersion>
                <reportDirectory>${basedir}/target/allure-results</reportDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

allure.properties

allure.Results.Directory = target/Allure-results

jenkins

结果路径:target/allure-results

jenkins jenkins并未创建Allure-Results文件夹。如果我自己创建一个文件夹,则报告的文件不适合工作空间

添加管道脚本

pipeline {
agent any

tools {
    // Install the Maven version configured as "M3" and add it to the path.
    
    maven "3.8.5"
}

stages {
    stage('Build') {
        steps {
            // Get some code from a GitHub repository
            git 'https://github.com/steed777/GoogleTest.git'

            // Run Maven on a Unix agent.
            bat "mvn -Dtest=com.github.steed777.common.runner.**verify"

            // To run Maven on a Windows agent, use
            // bat "mvn -Dmaven.test.failure.ignore=true clean package"
        }

        
    }
}
post{
    always{
        allure([
            
            includeProperties: false, jdk: '', results: [[path: 'target/allure-results']]
            ])
    }
}
}

Jenkins ignores properties and does not create allure-results. Please help.

pom.xml

<groupId>org.example</groupId>
<artifactId>GoogleTest</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
    <aspectj.version>1.8.10</aspectj.version>
    <allure.version>2.17.3</allure.version>
    <cucumber.version>7.2.3</cucumber.version>
</properties>

<dependencies>

    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-testng -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>${cucumber.version}</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>compile</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>4.4.1</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.reload4j</groupId>
        <artifactId>reload4j</artifactId>
        <version>1.2.19</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.5</version>
    </dependency>

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-testng</artifactId>
        <version>2.17.3</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-java-commons</artifactId>
        <version>2.17.3</version>
        <scope>compile</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/io.qameta.allure/allure-commandline -->
    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-commandline</artifactId>
        <version>2.17.3</version>
        <type>pom</type>
    </dependency>

    <dependency>
        <groupId>io.qameta.allure</groupId>
        <artifactId>allure-cucumber3-jvm</artifactId>
        <version>2.17.3</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.2</version>
        <scope>test</scope>
    </dependency>

</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.2</version>
            <configuration>

                <argLine>
                    -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                </argLine>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjweaver</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>io.qameta.allure</groupId>
            <artifactId>allure-maven</artifactId>
            <version>2.10.0</version>
            <configuration>
                <reportVersion>${allure.version}</reportVersion>
                <allureDownloadUrl>https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${allure.version}/allure-commandline-${allure.version}.zip</allureDownloadUrl>
                <reportVersion>${allure.version}</reportVersion>
                <reportDirectory>${basedir}/target/allure-results</reportDirectory>
            </configuration>
        </plugin>
    </plugins>
</build>

allure.properties

allure.results.directory=target/allure-results

jenkins

results path: target/allure-results

Jenkins does not create the allure-results folder. If I create a folder myself, the files for the report do not fit in the workspace

add pipeline script

pipeline {
agent any

tools {
    // Install the Maven version configured as "M3" and add it to the path.
    
    maven "3.8.5"
}

stages {
    stage('Build') {
        steps {
            // Get some code from a GitHub repository
            git 'https://github.com/steed777/GoogleTest.git'

            // Run Maven on a Unix agent.
            bat "mvn -Dtest=com.github.steed777.common.runner.**verify"

            // To run Maven on a Windows agent, use
            // bat "mvn -Dmaven.test.failure.ignore=true clean package"
        }

        
    }
}
post{
    always{
        allure([
            
            includeProperties: false, jdk: '', results: [[path: 'target/allure-results']]
            ])
    }
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可遇━不可求 2025-01-31 07:28:14

如果您希望与Jenkins合作,则需要安装Allure插件,并将其配置为管理Jenkins-&gt;全局工具配置 - &GT; Allure Commandline ...

然后在管道脚本中,您只需像这样调用魅力:

allure includeProperties: false, jdk: '', results: [[path: 'allure-results']]

allure命令的一部分必须匹配您在global global Configuration中为您设置的Allure的名称

If you want allure to work with Jenkins you need to install Allure plugin for it and configure it in Manage Jenkins -> Global Tool Configuration -> Allure Commandline...

Then inside your pipeline script, you simply call allure like this:

allure includeProperties: false, jdk: '', results: [[path: 'allure-results']]

the allure part of the command has to match the name you set for allure in Global Configuration.

傲影 2025-01-31 07:28:14

更改启动命令:bat“ MVN CLEAN TEST -DTEST = BDDRUNNER”

Changed the startup command: bat "mvn clean test -Dtest=BDDRunner"

莫言歌 2025-01-31 07:28:14

这个对我有用。希望它有帮助

stage('Generate Allure Report') { steps { script { ws('/path of project/') { allure([ includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'allure-results']] ]) } } } }

This one worked for me. Hope it helps

stage('Generate Allure Report') { steps { script { ws('/path of project/') { allure([ includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'allure-results']] ]) } } } }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文