-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
45 lines (44 loc) · 1.26 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
pipeline {
agent any
environment {
dockerhubrepo = "rdg5/examplepipeline"
dockeruser = "dockeruser"
image = ""
appname = "examplePipeline"
envname = "Examplepipeline-dev"
bucketname = "elasticbeanstalk-eu-west-3-124429370407"
}
stages {
stage('Install dependencies') {
steps {
sh 'npm i'
sh 'echo "build is done"'
}
}
stage('Deploy to dockerHub') {
steps {
script{
image = docker.build("rdg5/examplepipeline")
}
script{
docker.withRegistry('', "dockeruser"){
image.push()
}
}
}
}
stage('Deploy to ElasticBeanstalk') {
steps {
withAWS(credentials:"exampleid", region:"eu-west-3") {
sh 'aws s3 cp ./dockerrun.aws.json s3://${bucketname}/$BUILD_ID/dockerrun.aws.json'
sh 'aws elasticbeanstalk create-application-version \
--application-name "examplePipeline" --version-label "$BUILD_ID" \
--source-bundle S3Bucket="${bucketname}",S3Key="$BUILD_ID/dockerrun.aws.json" \
--auto-create-application'
sh 'aws elasticbeanstalk update-environment --application-name "examplePipeline" \
--environment-name "examplepipeline-dev" '
}
}
}
}
}