Set up Jenkins jobs for web and mobile tests
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
<?xml version='1.1' encoding='UTF-8'?>
|
||||
<flow-definition plugin="workflow-job">
|
||||
<description>Appium mobile tests with APK download and Allure report.</description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>REPO_URL</name>
|
||||
<description>Git repo with Appium tests (hw7)</description>
|
||||
<defaultValue>https://git.kovbasa.ru/otus-autotests/homework_7.git</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>BRANCH</name>
|
||||
<description>Git branch</description>
|
||||
<defaultValue>master</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>APP_URL</name>
|
||||
<description>APK URL (optional). If empty, repo APK will be used.</description>
|
||||
<defaultValue></defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>DB_URL</name>
|
||||
<description>JDBC url</description>
|
||||
<defaultValue>jdbc:postgresql://sql.otus.kartushin.su:5432/wishlist</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>DB_USER</name>
|
||||
<description>DB user</description>
|
||||
<defaultValue>student</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.PasswordParameterDefinition>
|
||||
<name>DB_PASSWORD</name>
|
||||
<description>DB password</description>
|
||||
</hudson.model.PasswordParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps">
|
||||
<script><![CDATA[
|
||||
pipeline {
|
||||
agent any
|
||||
triggers {
|
||||
pollSCM('H/5 * * * *')
|
||||
}
|
||||
parameters {
|
||||
string(name: 'REPO_URL', defaultValue: 'https://git.kovbasa.ru/otus-autotests/homework_7.git', description: 'Git repo with Appium tests (hw7)')
|
||||
string(name: 'BRANCH', defaultValue: 'master', description: 'Git branch')
|
||||
string(name: 'APP_URL', defaultValue: '', description: 'APK URL (optional)')
|
||||
string(name: 'DB_URL', defaultValue: 'jdbc:postgresql://sql.otus.kartushin.su:5432/wishlist', description: 'JDBC url')
|
||||
string(name: 'DB_USER', defaultValue: 'student', description: 'DB user')
|
||||
password(name: 'DB_PASSWORD', defaultValue: '', description: 'DB password')
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git branch: params.BRANCH, url: params.REPO_URL
|
||||
}
|
||||
}
|
||||
stage('Docker Compose') {
|
||||
steps {
|
||||
script {
|
||||
if (isUnix()) {
|
||||
def composeCmd = 'docker compose'
|
||||
if (sh(script: 'command -v docker-compose >/dev/null 2>&1', returnStatus: true) == 0) {
|
||||
composeCmd = 'docker-compose'
|
||||
}
|
||||
if (params.APP_URL?.trim()) {
|
||||
sh "APP_URL='${params.APP_URL}' ${composeCmd} up -d"
|
||||
} else {
|
||||
sh "${composeCmd} up -d"
|
||||
}
|
||||
} else {
|
||||
def composeCmd = 'docker compose'
|
||||
if (bat(script: 'where docker-compose', returnStatus: true) == 0) {
|
||||
composeCmd = 'docker-compose'
|
||||
}
|
||||
if (params.APP_URL?.trim()) {
|
||||
bat "set APP_URL=${params.APP_URL}&& ${composeCmd} up -d"
|
||||
} else {
|
||||
bat "${composeCmd} up -d"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
script {
|
||||
def mvn = isUnix() ? 'mvn' : 'mvn.cmd'
|
||||
if (isUnix()) {
|
||||
sh "DB_URL='${params.DB_URL}' DB_USER='${params.DB_USER}' DB_PASSWORD='${params.DB_PASSWORD}' ${mvn} -Dallure.results.directory=target/allure-results test"
|
||||
} else {
|
||||
bat "set DB_URL=${params.DB_URL}&& set DB_USER=${params.DB_USER}&& set DB_PASSWORD=${params.DB_PASSWORD}&& ${mvn} -Dallure.results.directory=target/allure-results test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
allure includeProperties: false, jdk: '', results: [[path: 'target/allure-results']]
|
||||
archiveArtifacts allowEmptyArchive: true, artifacts: 'target/**'
|
||||
script {
|
||||
if (isUnix()) {
|
||||
def composeCmd = 'docker compose'
|
||||
if (sh(script: 'command -v docker-compose >/dev/null 2>&1', returnStatus: true) == 0) {
|
||||
composeCmd = 'docker-compose'
|
||||
}
|
||||
sh "${composeCmd} down -v || true"
|
||||
} else {
|
||||
def composeCmd = 'docker compose'
|
||||
if (bat(script: 'where docker-compose', returnStatus: true) == 0) {
|
||||
composeCmd = 'docker-compose'
|
||||
}
|
||||
bat "${composeCmd} down -v"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></script>
|
||||
<sandbox>true</sandbox>
|
||||
</definition>
|
||||
<triggers/>
|
||||
<disabled>false</disabled>
|
||||
</flow-definition>
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version='1.1' encoding='UTF-8'?>
|
||||
<flow-definition plugin="workflow-job">
|
||||
<description>Selenium/Selenide tests with browser parameter and Allure report.</description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<properties>
|
||||
<hudson.model.ParametersDefinitionProperty>
|
||||
<parameterDefinitions>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>REPO_URL</name>
|
||||
<description>Git repo with Selenium/Selenide tests</description>
|
||||
<defaultValue>https://git.kovbasa.ru/otus-autotests/homework_4.git</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>BRANCH</name>
|
||||
<description>Git branch</description>
|
||||
<defaultValue>master</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.ChoiceParameterDefinition>
|
||||
<name>BROWSER</name>
|
||||
<description>Browser to run tests</description>
|
||||
<choices class="java.util.Arrays$ArrayList">
|
||||
<a class="string-array">
|
||||
<string>chrome</string>
|
||||
<string>firefox</string>
|
||||
</a>
|
||||
</choices>
|
||||
</hudson.model.ChoiceParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>BROWSER_VERSION</name>
|
||||
<description>Browser version (optional)</description>
|
||||
<defaultValue></defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>EXECUTION_MODE</name>
|
||||
<description>local or selenoid</description>
|
||||
<defaultValue>local</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>SELENOID_URL</name>
|
||||
<description>Selenoid URL (used when execution.mode=selenoid)</description>
|
||||
<defaultValue>http://localhost/wd/hub</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.StringParameterDefinition>
|
||||
<name>BASE_URL</name>
|
||||
<description>Base URL for tests</description>
|
||||
<defaultValue>https://otus.ru</defaultValue>
|
||||
<trim>true</trim>
|
||||
</hudson.model.StringParameterDefinition>
|
||||
<hudson.model.ChoiceParameterDefinition>
|
||||
<name>HEADLESS</name>
|
||||
<description>Run browsers in headless mode</description>
|
||||
<choices class="java.util.Arrays$ArrayList">
|
||||
<a class="string-array">
|
||||
<string>true</string>
|
||||
<string>false</string>
|
||||
</a>
|
||||
</choices>
|
||||
</hudson.model.ChoiceParameterDefinition>
|
||||
</parameterDefinitions>
|
||||
</hudson.model.ParametersDefinitionProperty>
|
||||
</properties>
|
||||
<definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps">
|
||||
<script><![CDATA[
|
||||
pipeline {
|
||||
agent any
|
||||
triggers {
|
||||
pollSCM('H/5 * * * *')
|
||||
}
|
||||
parameters {
|
||||
string(name: 'REPO_URL', defaultValue: 'https://git.kovbasa.ru/otus-autotests/homework_4.git', description: 'Git repo with Selenium/Selenide tests')
|
||||
string(name: 'BRANCH', defaultValue: 'master', description: 'Git branch')
|
||||
choice(name: 'BROWSER', choices: ['chrome', 'firefox'], description: 'Browser to run tests')
|
||||
string(name: 'BROWSER_VERSION', defaultValue: '', description: 'Browser version (optional)')
|
||||
string(name: 'EXECUTION_MODE', defaultValue: 'local', description: 'local or selenoid')
|
||||
string(name: 'SELENOID_URL', defaultValue: 'http://localhost/wd/hub', description: 'Selenoid URL')
|
||||
string(name: 'BASE_URL', defaultValue: 'https://otus.ru', description: 'Base URL for tests')
|
||||
choice(name: 'HEADLESS', choices: ['true', 'false'], description: 'Run browsers in headless mode')
|
||||
}
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git branch: params.BRANCH, url: params.REPO_URL
|
||||
}
|
||||
}
|
||||
stage('Test') {
|
||||
steps {
|
||||
script {
|
||||
def mvn = isUnix() ? 'mvn' : 'mvn.cmd'
|
||||
def extra = isUnix() ? " -Dchrome.binary=/usr/bin/chromium" : ""
|
||||
def cmd = "${mvn} -Dexecution.mode=${params.EXECUTION_MODE} -Dbrowser=${params.BROWSER} -Dbrowser.version=${params.BROWSER_VERSION} -Dselenoid.url=${params.SELENOID_URL} -Dbase.url=${params.BASE_URL} -Dselenide.headless=${params.HEADLESS} -Dallure.results.directory=target/allure-results${extra} test"
|
||||
if (isUnix()) {
|
||||
sh cmd
|
||||
} else {
|
||||
bat cmd
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
allure includeProperties: false, jdk: '', results: [[path: 'target/allure-results']]
|
||||
archiveArtifacts allowEmptyArchive: true, artifacts: 'target/**'
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></script>
|
||||
<sandbox>true</sandbox>
|
||||
</definition>
|
||||
<triggers/>
|
||||
<disabled>false</disabled>
|
||||
</flow-definition>
|
||||
Reference in New Issue
Block a user