I'm using declarative pipeline for jenkins and my goal is to have a separated virtual environment for each project in jenkins/workspace. I've created a new pipeline with the following code:
pipeline {
agent any
stages {
stage('Pull all changes') {
steps {
git branch: "master", url: "git@fancylink.git"
}
}
stage('Create and Activate venv') {
steps {
sh 'python3.11 -m venv venv'
sh 'source venv/bin/activate'
}
}
}
post {
always {
sh 'deactivate'
}
}
}
However I'm getting this error:
When I try to do the same steps via SSH everything is working fine and venv is activated. Also I don't know if it's important but I have 2 version of the python on the server (python3.9, python3.11)