Skip to content

Commit 17caed6

Browse files
Update Jenkinsfile
1 parent 2a32ac7 commit 17caed6

File tree

1 file changed

+61
-60
lines changed

1 file changed

+61
-60
lines changed

Jenkinsfile

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,77 @@
11
pipeline {
2-
agent any
2+
agent any
33

4-
environment {
5-
SERVERLESS_ACCESS_KEY = credentials('SERVERLESS_ACCESS_KEY')
6-
PATH = "/usr/bin:$PATH"
7-
}
8-
9-
stages {
10-
stage('Checkout Code') {
11-
steps {
12-
checkout scm
13-
}
14-
}
15-
16-
stage('Check Environment') {
17-
steps {
18-
sh '''
19-
echo "Checking Python version..."
20-
python3 --version
4+
environment {
5+
STAGE = "dev"
6+
}
217

22-
echo "Checking Node version..."
23-
node -v
8+
stages {
9+
stage('Checkout Code') {
10+
steps {
11+
checkout scm
12+
}
13+
}
2414

25-
echo "Checking npm version..."
26-
npm -v
15+
stage('Check Environment') {
16+
steps {
17+
sh '''
18+
echo Checking Python version...
19+
python3 --version
2720
28-
echo "Checking Serverless version..."
29-
command -v serverless || { echo "❌ Serverless CLI not found"; exit 1; }
21+
echo Checking Node version...
22+
node -v
3023
31-
echo "✅ Environment looks good."
32-
'''
33-
}
34-
}
24+
echo Checking npm version...
25+
npm -v
3526
36-
stage('Install Dependencies') {
37-
steps {
38-
sh '''
39-
echo "Installing Python virtual environment..."
40-
python3 -m venv venv
41-
. venv/bin/activate
27+
echo Checking Serverless version...
28+
command -v serverless
29+
echo ✅ Environment looks good.
30+
'''
31+
}
32+
}
4233

43-
echo "Installing Python dependencies..."
44-
pip install --upgrade pip
45-
pip install -r requirements.txt
34+
stage('Install Dependencies') {
35+
steps {
36+
sh '''
37+
echo Installing Python virtual environment...
38+
python3 -m venv venv
39+
. venv/bin/activate
40+
echo Installing Python dependencies...
41+
pip install --upgrade pip
42+
pip install -r requirements.txt
4643
47-
echo "Installing Node dependencies..."
48-
npm install
44+
echo Installing Node dependencies...
45+
npm install
4946
50-
echo "Installing Serverless WSGI plugin if needed..."
51-
npm install --save serverless-wsgi
52-
'''
53-
}
54-
}
47+
echo Installing Serverless WSGI plugin if needed...
48+
npm install --save serverless-wsgi
49+
'''
50+
}
51+
}
5552

56-
stage('Deploy to AWS Lambda') {
57-
steps {
58-
withCredentials([string(credentialsId: 'SERVERLESS_ACCESS_KEY', variable: 'SERVERLESS_ACCESS_KEY')]) {
59-
sh '''
60-
echo "Deploying with Serverless CLI..."
61-
serverless deploy --stage dev --verbose
62-
'''
63-
}
64-
}
53+
stage('Deploy to AWS Lambda') {
54+
steps {
55+
withCredentials([
56+
string(credentialsId: 'serverless-key', variable: 'SERVERLESS_ACCESS_KEY'),
57+
usernamePassword(credentialsId: 'aws-credentials', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_ACCESS_KEY')
58+
]) {
59+
sh '''
60+
echo Deploying with Serverless CLI...
61+
serverless deploy --stage $STAGE --verbose
62+
'''
6563
}
64+
}
6665
}
66+
}
6767

68-
post {
69-
success {
70-
echo '✅ Deployment successful!'
71-
}
72-
failure {
73-
echo '❌ Pipeline failed. Check logs above.'
74-
}
68+
post {
69+
failure {
70+
echo "❌ Pipeline failed. Check logs above."
71+
}
72+
success {
73+
echo "✅ Deployed successfully to AWS Lambda!"
7574
}
75+
}
7676
}
77+

0 commit comments

Comments
 (0)