Skip to content

Commit 9f211aa

Browse files
committed
yes
1 parent d5beccb commit 9f211aa

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

Jenkinsfile

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,18 @@ pipeline {
4040
steps {
4141
echo 'Deploy to QA'
4242
sh 'pwd'
43-
sh 'zip -g bermtec-0.0.1.zip target/bermtec-0.0.1.jar'
44-
45-
sh 'aws --version'
46-
sh 'aws s3 ls'
43+
sh 'zip -g bermtec-0.0.1.zip target/bermtec-0.0.1.jar'
44+
4745
sh 'aws configure set aws_access_key_id $AWS_ACCESS_KEY'
4846
sh 'aws configure set aws_secret_access_key $AWS_SECRET_KEY'
49-
// sh 'aws configure set region us-east-1'
47+
sh 'aws configure set region us-east-1'
5048
sh 'aws s3 cp bermtec-0.0.1.zip s3://bermtec228/lambda-test/'
5149
echo "Stage 2 Yes"
50+
functionName = 'test'
51+
if (does_lambda_exist($functionName)) {
5252
// sh './deploy-test.sh $AWS_ACCESS_KEY $AWS_SECRET_KEY'
53-
sh 'aws lambda update-function-code --function-name test --zip-file fileb://./target/bermtec-0.0.1.zip'
53+
sh 'aws lambda update-function-code --function-name $functionName --zip-file fileb://./target/bermtec-0.0.1.zip'
54+
}
5455
}
5556
}
5657

@@ -73,8 +74,12 @@ pipeline {
7374
echo 'Deploy to Prod'
7475
sh 'aws configure set aws_access_key_id $AWS_ACCESS_KEY'
7576
sh 'aws configure set aws_secret_access_key $AWS_SECRET_KEY'
76-
sh 'aws s3 cp bermtec-0.0.1.zip s3://bermtec28/lambdaprod'
77-
sh 'aws lambda update-function-code --function-name prodfunction --zip-file fileb://bermtec-0.0.1.zip'
77+
sh 'aws s3 cp bermtec-0.0.1.zip s3://bermtec288/lambda-prod'
78+
functionName = 'test'
79+
if (does_lambda_exist($functionName)) {
80+
echo 'Function Exists'
81+
sh 'aws lambda update-function-code --function-name prodfunction --s3-bucket bermtec288 --s3-key lambda-prod/bermtec-0.0.1.zip'
82+
}
7883
}
7984
}
8085
}
@@ -95,4 +100,18 @@ pipeline {
95100
echo 'aborted'
96101
}
97102
}
103+
}
104+
105+
def does_lambda_exist(name) {
106+
isexist=false
107+
echo $name
108+
try{
109+
sh 'aws lambda get-function --function-name $name'
110+
isexist=true
111+
}
112+
catch {
113+
echo 'Failed'
114+
isexist=true
115+
}
116+
return isexist
98117
}

src/main/java/com/example/bermtec/GreetingController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
public class GreetingController {
66
public String greeting(String input, Context context) {
77
context.getLogger().log("User Input : " + input);
8-
return "Welcome to Bermtec : " + input;
8+
return "Welcome to Bermtec 28 : " + input;
99
}
1010
}

0 commit comments

Comments
 (0)