I am trying to execute tests with python3 behave module. As a part of pipeline , behave command is executed and throws below error in logs:
Jenkins does not seem to be running inside a container $ docker run -t -d -u 113:119 -v /etc/passwd:/etc/passwd -v /var/lib/jenkins/.ssh:/var/lib/jenkins/.ssh -v /var/lib/jenkins/workspace/Mtr-Pipeline_develop/gaut:/var/lib/jenkins/workspace/Mtr-Pipeline_develop/gaut -w /var/lib/jenkins/workspace/Mtr-Pipeline_develop -v /var/lib/jenkins/workspace/Mtr-Pipeline_develop:/var/lib/jenkins/workspace/Mtr-Pipeline_develop:rw,z -v /var/lib/jenkins/workspace/Mtr-Pipeline_develop@tmp:/var/lib/jenkins/workspace/Mtr-Pipeline_develop@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** python:3.6.8 cat $ docker top 123xyz -eo pid,comm [Pipeline] { [Pipeline] sh
- mkdir -p gaut [Pipeline] dir Running in /var/lib/jenkins/workspace/Mtr-Pipeline_develop/gaut
- cd gaut
- python3 -m venv .env
- . .env/bin/activate
- deactivate nondestructive
- [ -n ]
- [ -n ]
- [ -n -o -n ]
- [ -n ]
- unset VIRTUAL_ENV
- [ ! nondestructive = nondestructive ]
- VIRTUAL_ENV=/var/lib/jenkins/workspace/Mtr-Pipeline_develop/gaut/.env
- export VIRTUAL_ENV
- _OLD_VIRTUAL_PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- PATH=/var/lib/jenkins/workspace/Mtr-Pipeline_develop/gaut/.env/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- export PATH
- [ -n ]
- [ -z ]
- _OLD_VIRTUAL_PS1=$
- [ x(.env) != x ]
- PS1=(.env) $
- export PS1
- [ -n -o -n ]
- python3 -m pip install -r requirements.txt --no-cache-dir Requirement ******* You should consider upgrading via the 'pip install --upgrade pip' command.
- behave --no-capture -D guser=aabc -D gpwd=**** -D suser=YAPP_TM -D spwd= **** --tags=@Mtr /var/lib/jenkins/workspace/Mtr-Pipeline_develop@tmp/durable-4b44ebd7/script.sh: 1: /var/lib/jenkins/workspace/Mtr-Pipeline_develop@tmp/durable-4b44ebd7/script.sh: behave: not found [Pipeline] } [Pipeline] // withCredentials [Pipeline] } $ docker stop --time=1 123xyz $ docker rm -f 123xyz
I wish to execute behave command with the same user Jenkins as in the host, that is why I have mapped three files under docker.image. I have a mention of behave already in requirements.txt file.
Code:
stage("Test - ${ENV}"){
docker.image('python:3.6.8').inside('-v /etc/passwd:/etc/passwd -v /var/lib/jenkins/.ssh:/var/lib/jenkins/.ssh -v /var/lib/jenkins/workspace/Mtr-Main-Pipeline_develop/gaut:/var/lib/jenkins/workspace/Mtr-Main-Pipeline_develop/gaut'){
sh 'mkdir -p gaut'
dir("gaut")
{
git(url: "git@ssh-gitlab.rwts-tools.com:dpo/d2p/abc/gsk/cicd_abc-gsk-validation.git", branch: "master", credentialsId: 'ashish-personal-ssh-key')
}
withCredentials([
***
])
{
sh "ssh -o StrictHostKeyChecking=no -i $keyfile -M -S ctrl-socket -f -N -L 5432:${Config.dbhost.get(env.BRANCH_NAME, "abc-np.xyz.us-east-1.rds.amazonaws.com")}:5432 ${Config.jumphostForDB.get(env.BRANCH_NAME, "ubuntu@10.x.x.x")}"
sh "cd gaut; python3 -m venv .env;. .env/bin/activate; python3 -m pip install -r requirements.txt --no-cache-dir;pip install behave --user; behave --no-capture -D guser=${some-var} -D gpwd=${some-var} -D suser=${some-var} -D spwd= ${some-var} --tags=@Mtr"
}
}
}
Can someone please assist here.