Getting error with python behave while running in Jenkins pipeline

Viewed 36

The pipeline is failing while using this command

behave --no-capture -D gduser=atm -D gdbpwd=**** -D suser=*** -D spwd= **** --tags=@Mtr

Jenkins console output:

***
+ ssh -o StrictHostKeyChecking=no -i **** -M -S ctrl-socket -f -N -L 5432:t-n.c.us-east-1.rds.amazonaws.com:5432 ubuntu@10.x.x.x
bind [127.0.0.1]:5432: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 5432
Could not request local forwarding.
[Pipeline] echo
Now running ALL tests
[Pipeline] sh
***
+ behave --no-capture -D gduser=atm -D gdbpwd=**** -D suser=*** -D spwd= **** --tags=@Mtr
ConfigError: No steps directory in '/var/lib/jenkins/workspace/***_develop@2/****'

Now running the pipeline with the command

behave --tags=@Mtr -f allure_behave.formatter:AllureFormatter -o /var/lib/jenkins/workspace/***_develop@2/allure-results --no-capture -e proddb_report_generation.feature
***
+ ssh -o StrictHostKeyChecking=no -i **** -M -S ctrl-socket -f -N -L 5432:t-n.c.us-east-1.rds.amazonaws.com:5432 ubuntu@10.x.x.x
bind [127.0.0.1]:5432: Address already in use
channel_setup_fwd_listener_tcpip: cannot listen to port: 5432
Could not request local forwarding.
[Pipeline] echo
Now running ALL tests
[Pipeline] sh
+ behave --tags=@Mtr -f allure_behave.formatter:AllureFormatter -o /var/lib/jenkins/workspace/***_develop@2/allure-results --no-capture -e proddb_report_generation.feature

You can implement step definitions for undefined steps with these snippets:

given(u'Db Connected')
def step_impl(context):
    raise NotImplementedError(u'STEP: Given Db Connected')


given(u'Delete m*** p*** data')
def step_impl(context):
    raise NotImplementedError(u'STEP: Given Delete m*** p*** data')

But the same pipeline is working fine with the command

behave --tags=~@arch -f allure_behave.formatter:AllureFormatter -o /var/lib/jenkins/workspace/***_develop@2/allure-results --no-capture -e proddb_report_generation.feature
+ ssh -o StrictHostKeyChecking=no -i **** -M -S ctrl-socket -f -N -L 5432:t-n.c.us-east-1.rds.amazonaws.com:5432 ubuntu@10.x.x.x
[Pipeline] echo
Now running ALL tests
[Pipeline] sh
+ behave --tags=~@arch -f allure_behave.formatter:AllureFormatter -o /var/lib/jenkins/workspace/***_develop@2/allure-results --no-capture -e proddb_report_generation.feature
database connected successfully.
database connected successfully.
Starting execution of feature 'Validating p*** status for single and multiprotocol'
Matching status is done : 200
Now running scenario: ***: Validate p*** matching status -- u/1.1

Below is the Jenkins code:

stage('Run Mtr Tests') {
            // agent {
            //     docker {
            //         image 'python:3.6.8'
            //         reuseNode true
            //      }
            // }
           agent any 
            steps {
                script{
                   ***"
                   withCredentials([
                        usernamePassword(credentialsId: ***)
                        ]){
                          withEnv(["ENVIRONMENT=${environment}",
                                  "BROWSER=Chrome",
                                  "JENKINS=testing",
                                  ***
                                  ]){
                                      sh "python --version"
                                      sh "virtualenv --no-site-packages .env ; . .env/bin/activate;pip install --target ${env.WORKSPACE} -r requirements.txt --no-cache-dir"
                                      sh "ssh -o StrictHostKeyChecking=no -i *** -M -S ctrl-socket -f -N -L 5432:${Config.dbhost.get(env.BRANCH_NAME, "t-n.c.us-east-1.rds.amazonaws.com")}:5432 ${Config.jumphostForDB.get(env.BRANCH_NAME, "ubuntu@10.x.x.x")}"
                                       if (run_parameter == 'all') {
                                         echo "Now running ALL tests"
                                         //allure serve -h localhost
                                         //sh "behave --tags=@Mtr -f allure_behave.formatter:AllureFormatter -o allure-results --no-capture"
                                         sh "behave --tags=~@arch -f allure_behave.formatter:AllureFormatter -o ${WORKSPACE}/allure-results --no-capture -e proddb_report_generation.feature"
                                        // sh "allure serve allure-results"
                                        // echo "test completed"
                                           
                                       }
                                }
                        }
                }
            }

Could someone please provide some pointers. I have deliberately kept few commented Jenkins code unedited here as there must be some answer in them. I am very inexperienced with python behave framework and using this the very first time in a pipeline

0 Answers
Related