141 lines
5.5 KiB
XML
141 lines
5.5 KiB
XML
<?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.StringParameterDefinition>
|
|
<name>APPIUM_URL</name>
|
|
<description>Appium server URL</description>
|
|
<defaultValue>http://docker:4723</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')
|
|
string(name: 'APPIUM_URL', defaultValue: 'http://docker:4723', description: 'Appium server URL')
|
|
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} -Dappium.url=${params.APPIUM_URL} -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} -Dappium.url=${params.APPIUM_URL} -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>
|