@@ -2,48 +2,52 @@ pipeline {
22 agent any
33
44 environment {
5- // Add serverless CLI directory to PATH
6- PATH = " /mnt/c/Users/inbox/AppData/Roaming/npm:$PATH "
7- VENV = ' venv'
8- PYTHON = ' ./venv/bin/python'
9- PIP = ' ./venv/bin/pip'
5+ VENV_DIR = ' .venv'
106 }
117
128 stages {
139 stage(' Check Environment' ) {
1410 steps {
1511 sh '''
16- echo "Checking Python version..."
17- python3 --version
18-
19- echo "Checking Node version..."
20- node -v
21-
22- echo "Checking npm version..."
23- npm -v
24-
25- echo "Checking Serverless version..."
26- /mnt/c/Users/inbox/AppData/Roaming/npm/serverless --version
12+ echo Checking Python version...
13+ python3 --version || { echo "Python 3 not found"; exit 1; }
14+
15+ echo Checking Node version...
16+ node -v || { echo "Node.js not found"; exit 1; }
17+
18+ echo Checking npm version...
19+ npm -v || { echo "npm not found"; exit 1; }
20+
21+ echo Checking Serverless version...
22+ if ! command -v serverless &> /dev/null; then
23+ echo "Serverless CLI not found"
24+ exit 1
25+ fi
2726 '''
2827 }
2928 }
3029
3130 stage(' Setup Python Virtualenv' ) {
3231 steps {
3332 sh '''
34- python3 -m venv ${VENV}
35- ${PIP} install --upgrade pip
36- ${PIP} install -r requirements.txt
33+ echo Creating virtual environment...
34+ python3 -m venv $VENV_DIR
35+ source $VENV_DIR/bin/activate
36+ pip install --upgrade pip
37+ pip install -r requirements.txt
3738 '''
3839 }
3940 }
4041
4142 stage(' Deploy to AWS Lambda' ) {
4243 steps {
43- sh '''
44- echo "Deploying with Serverless CLI..."
45- /mnt/c/Users/inbox/AppData/Roaming/npm/serverless deploy --stage dev
46- '''
44+ withCredentials([string(credentialsId : ' SERVERLESS_ACCESS_KEY' , variable : ' SERVERLESS_ACCESS_KEY' )]) {
45+ sh '''
46+ echo Deploying with Serverless CLI...
47+ export SERVERLESS_ACCESS_KEY=$SERVERLESS_ACCESS_KEY
48+ serverless deploy --stage dev
49+ '''
50+ }
4751 }
4852 }
4953 }
@@ -57,3 +61,4 @@ pipeline {
5761 }
5862 }
5963}
64+
0 commit comments