import com.urbancode.air.*
import com.urbancode.air.plugin.automation.*

final def apTool = new AirPluginTool(this.args[0], this.args[1])
final def workDir = new File('.').canonicalFile
def stepProps = apTool.getStepProperties()

def dir = new File(workDir, stepProps['workDirOffset'] ?: '.').canonicalFile

def serverUrl = stepProps['automation/serverUrl']
def username = stepProps['automation/username']
def password = stepProps['automation/password'] ? stepProps['automation/password'] : stepProps['automation/passwordscript']

def domain = stepProps['qcdomain']
def project = stepProps['qcproject']
def folder = stepProps['folder']
def testSetName = stepProps['testSetName']
def remoteHost = stepProps['remotehost']
def reportName = stepProps['reportName']
def jobId = System.getenv('JOB_ID')

QCPublishTestReport report = new QCPublishTestReport()
report.serverUrl = serverUrl
report.username = username
report.password = password
report.domain = domain
report.project = project

report.folder = folder
report.testSetName = testSetName
report.remoteHost = remoteHost
report.reportName = reportName
report.jobId = jobId

report.workDir = dir

report.execute()
