Sep-20-2024, 04:07 PM
(This post was last modified: Sep-20-2024, 04:07 PM by NikitaMathur.)
Hi, I am working to create a new pipeline to run test cases from my Python repository in Jenkins. have created a 'Jenkinsfile' defining the different stages that I would need, however I'm unable to create a virtual environment for Python to run.
Can someone help what i am missing?
Can someone help what i am missing?
#!/usr/bin/env groovy
properties([
pipelineTriggers([
pollSCM('*/1 * * * *')
]),
disableConcurrentBuilds()
])
node {
env.GIT_PROJECT_NAME = "*******"
//PYTHON_VERSION = "3.12" // Specify the Python version
VENV_DIR = "venv" // Directory for the virtual environment
ALLURE_RESULTS_DIR = "allure-results" // Directory for Allure results
// Credentials for TFSFSService SSH user
def GIT_CREDENTIALS_ID = '*******'
def branchName = "${env.BRANCH_NAME}"
try {
stage ('Checkout') {
git(
poll: true,
url: "[email protected]:v3/d***d/***/${env.GIT_PROJECT_NAME}",
credentialsId: GIT_CREDENTIALS_ID,
branch: branchName
)
}
stage('Setup Python Environment') {
// Create a virtual environment
echo 'python --version'
bat 'python3 -m venv ${VENV_DIR}'
bat '${VENV_DIR}\\bin\\activate'
}
}
catch (e) {
throw e
}
}Getting the below error currently:Error:[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Setup Python Environment)
[Pipeline] echo
python --version
[Pipeline] bat
C:\Users\Jenkins\AppData\Local\Jenkins\.jenkins\workspace\st_thymeit-auto-base_development>python -m venv ${VENV_DIR}
Actual environment location may have moved due to redirects, links or junctions.
Requested location: "C:\Users\Jenkins\AppData\Local\Jenkins\.jenkins\workspace\st_######\${VENV_DIR}\Scripts\python.exe"
Actual location: "D:\jenkins\workspace\st_####\${VENV_DIR}\Scripts\python.exe"
[Pipeline] bat
C:\Users\Jenkins\AppData\Local\Jenkins\.jenkins\workspace\st_thymeit-auto-base_development>${VENV_DIR}\bin\.activate
The system cannot find the path specified.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
