Skip to content

Commit

Permalink
Update Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Aahil13 committed May 19, 2024
1 parent 0600715 commit 048b2d3
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
Empty file added .scannerwork/.sonar_lock
Empty file.
6 changes: 6 additions & 0 deletions .scannerwork/report-task.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
projectKey=Test-project
serverUrl=http://localhost:9000
serverVersion=10.5.1.90531
dashboardUrl=http://localhost:9000/dashboard?id=Test-project
ceTaskId=6f4e4d31-6df9-46c6-8095-df8e3dfd5321
ceTaskUrl=http://localhost:9000/api/ce/task?id=6f4e4d31-6df9-46c6-8095-df8e3dfd5321
56 changes: 56 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pipeline {
agent any

stages {
stage('Configure') {
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/Aahil13/Word-counter']])
}
}
stage('Building image') {
steps {
sh 'docker build -t word-counter .'
}
}

stage('Pushing to ECR') {
steps {
withAWS(credentials: 'AWS-CREDS', region: 'us-east-1') {
sh 'aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 313382416572.dkr.ecr.us-east-1.amazonaws.com'
sh 'docker tag word-counter:latest 313382416572.dkr.ecr.us-east-1.amazonaws.com/jenkins:latest'
sh 'docker push 313382416572.dkr.ecr.us-east-1.amazonaws.com/jenkins:latest'
}
}
}

stage('K8S Deploy') {
steps {
script {
withAWS(credentials: 'AWS-CREDS', region: 'us-east-1') {
sh 'aws eks update-kubeconfig --name test-cluster --region us-east-1'
sh 'kubectl apply -f EKS-Deployment.yaml'
}
}
}
}

stage('Get Service URL') {
steps {
script {
def serviceUrl = ""
// Wait for the LoadBalancer IP to be assigned
timeout(time: 5, unit: 'MINUTES') {
while(serviceUrl == "") {
serviceUrl = sh(script: "kubectl get svc word-counter-service -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'", returnStdout: true).trim()
if(serviceUrl == "") {
echo "Waiting for the LoadBalancer IP..."
sleep 10
}
}
}
echo "Service URL: http://${serviceUrl}"
}
}
}
}
}
15 changes: 15 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# must be unique in a given SonarQube instance
sonar.projectKey=Test-project

# --- optional properties ---

# defaults to project key
#sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Defaults to .
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

0 comments on commit 048b2d3

Please sign in to comment.