How to read flags on jenkins jobs

Viewed 652

We have two scripts (one for Katalon and one for Python) that we want to launch from Jenkins. First we want to launch Katalon and, at a certain point in the script, tell Jenkins that launch the python script. Then finished the python script, Jenkins should tell katalon that can continue.

Current jenkins pipeline code:

"pipeline {
       agent any
    
       stages {
          stage('Unit Test') {
             steps {
                echo 'Hello Example'
                bat """./katalon -noSplash -runMode=console projectPath="/Users/mypc/project/proyect1/example.prj" -retry=0 - 
    testSuitePath="Test Suites/IOS/TestSuiteAccount" -executionProfile="default" - 
    deviceId="example" -browserType="iOS" """
                sleep 5
             }
          }
          stage('Unit Test2') {
             steps {
                echo 'Start second test'
                bat """python  C:\\Users\\myPC\\Documents\\project\\project-katalon-code\\try_python.py"""
                sleep 5
             }
          }
       }
    }"

In pseudocode it would be the following:

Katalon script:

my_job()
call_jenkins_to_start_python()
if jenkins.python_flag == True
    my_job_continue()

Pipeline Jenkins script:

Katalon.start()
if katalon_sent_signal_to_start_python == True
    start_python_job()
if python_finished_job_signal == True
    send_katalon_signal_to_continue()

Would be a good solution to read/write an external file? Didn't find anything similar.

Thank you!

1 Answers

AFAIK, jenkins starts a sparate process for the bat () step and waits for it to finish. Also, communication between jenkins and the bat process is not possible: you trigger the script and you read the returned value and, if needed, stdout.

Additionally, I do not know if it is possible what you want, because I do not know Katalon at all. What you want requires Katalon waiting for a result from the python script and then, when this results reach Katalon, it should resume its execution.

I recommend you to first try the process without Jenkins: Create a windows script that does exactly what you want. If you are able to do that, you can then call that new script from jenkins, giving input or reading outputs as needed. Even as you suggested, using files for that.

Related