Hey. Tell me please,
There is a project, auto-tests, which, for example, create some essence. The data for these entities is taken either from .properties by keys or from .txt documents again from resources (directory).
Now the task, put it on jenkins and configure Joby with the ability to run with different values. Lay out something laid out, everything is going, but with the data that is in the files inside the project.
Found that in Jenkins you can customize parameterization, i.e. run with parameter.
I decided to do this (take an example, that when we build, we need to change the URL, this is an example, that is, instead of URL, there can be absolutely any value and there can be several of them):
- I create a Job Item on Jenkins, specify the parameter
"This project is parameterized" = True
Create a variable:
String Parameter Name = generalUrl Default Value = http://ru.stackoverflow.com further, I specify that this job item should be built using maven , the path to pom.xml and all that. And in goal I register - clean test
Save.
- I go to the project, in the pom.xml file I specify
http://maven.apache.org/maven-v4_0_0.xsd "> 4.0.0
<groupId>com</groupId> <artifactId>erm-nav-qa-integration-test</artifactId> <version>1.0-SNAPSHOT</version> <properties> <selenium.java.version>2.53.1</selenium.java.version> <testng.version>6.9.10</testng.version> <selenide.version>3.9.2</selenide.version> <junit.vesrion>4.12</junit.vesrion> <allure.version>1.4.23</allure.version> <maven.surefire.version>2.19.1</maven.surefire.version> <aspectj.version>1.8.5</aspectj.version> <maven.compiler.version>3.5.1</maven.compiler.version> <jetty.version>9.3.11.v20160721</jetty.version> <allure.maven.version>2.5</allure.maven.version> <apache.poi.version>3.9</apache.poi.version> <suiteName>smoke_ui_tests.xml</suiteName> <generalUrl>http://ru.stackoverflow.com</generalUrl> </properties> <dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>${testng.version}</version> </dependency> <dependency> <groupId>com.codeborne</groupId> <artifactId>selenide</artifactId> <version>${selenide.version}</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.vesrion}</version> </dependency> <dependency> <groupId>ru.yandex.qatools.allure</groupId> <artifactId>allure-testng-adaptor</artifactId> <version>${allure.version}</version> <exclusions> <exclusion> <groupId>junit</groupId> <artifactId>junit</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>${apache.poi.version}</version> <exclusions> <exclusion> <artifactId>xml-apis</artifactId> <groupId>xml-apis</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>${apache.poi.version}</version> <exclusions> <exclusion> <artifactId>xml-apis</artifactId> <groupId>xml-apis</groupId> </exclusion> </exclusions> </dependency> </dependencies> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>3.0.1</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven.surefire.version}</version> <configuration> <suiteXmlFiles> <suiteXmlFile>${suiteName}</suiteXmlFile> </suiteXmlFiles> <testFailureIgnore>true</testFailureIgnore> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" </argLine> <properties> <testUrl>${generalUrl}</testUrl> </properties> </configuration> <dependencies> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>${aspectj.version}</version> </dependency> </dependencies> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.compiler.version}</version> <configuration> <source>1.8</source> <target>1.8</target> <showWarnings>true</showWarnings> <showDeprecation>true</showDeprecation> </configuration> </plugin> <!--Needed only to show reports locally. Run jetty:run and open localhost:8080 to show the report--> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>${jetty.version}</version> <configuration> <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory> <stopKey>stop</stopKey> <stopPort>1234</stopPort> </configuration> </plugin> </plugins> </pluginManagement> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> <reporting> <excludeDefaults>true</excludeDefaults> <plugins> <plugin> <groupId>ru.yandex.qatools.allure</groupId> <artifactId>allure-maven-plugin</artifactId> <version>${allure.maven.version}</version> <configuration> <properties> <outputDirectory>${basedir}/target/allure-reports/</outputDirectory> <allureResultsDirectory>${basedir}/target/allure-results</allureResultsDirectory> </properties> </configuration> </plugin> </plugins> <outputDirectory>${basedir}/site</outputDirectory> </reporting> There is a key with the value baseUrl=${generalUrl} .properties file. It seems to have done everything as I found bit by bit somewhere, I run my tests, I get the error:
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32603,"message":"Cannot navigate to invalid URL"} (Session info: chrome=53.0.2785.89) I turn on the debugger and see that at the stage of reading the .properties file, the system takes just ${generalUrl} , i.e. just like text ...
Tell me how you can transfer variables from Jenkins. how to configure pom.xml , .properties so that you can perform a parameterized launch.
Thank.
UPD: Added pom.xml
.properties- Aleksandr.propertiesfile And what to write? ... - Andrey Yaremenko