-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
atakang7
committed
Sep 13, 2024
1 parent
def3d43
commit 53da298
Showing
13 changed files
with
187 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
def incrementVersion(String version) { | ||
def parts = version.split('\\.') | ||
def lastPart = parts.last() | ||
def newLastPart = (lastPart.toInteger() + 1).toString() | ||
parts[parts.size() - 1] = newLastPart | ||
return parts.join('.') | ||
} | ||
|
||
return incrementVersion(env.currentVersion) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
steps { | ||
input message: 'Approve deployment to production?', ok: 'Deploy' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
steps { | ||
script { | ||
// Build the Docker image with the specified version | ||
sh "docker build -t ${DOCKER_REGISTRY}/${APP_NAME}:${env.NEW_VERSION} ." | ||
|
||
// Push the Docker image to the registry | ||
sh "docker push ${DOCKER_REGISTRY}/${APP_NAME}:${env.NEW_VERSION}" | ||
|
||
// Verify that the image was pushed successfully | ||
sh "docker pull ${DOCKER_REGISTRY}/${APP_NAME}:${env.NEW_VERSION}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
steps { | ||
git url: 'https://github.com/AtakanG7/web-app', branch: 'main' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
steps { | ||
sh "git clone ${HELM_REPO} helm-repo" | ||
sh "helm repo add myrepo https://atakang7.github.io/gh-pages/docs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
steps { | ||
script { | ||
dir('helm-repo') { | ||
sh """ | ||
helm repo update | ||
helm upgrade --install ${APP_NAME} ${CHART_PATH} \ | ||
--namespace production \ | ||
-f ${CHART_PATH}/values-production.yaml \ | ||
--set image.tag=${env.NEW_VERSION} \ | ||
--wait --timeout 10m | ||
""" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
steps { | ||
script { | ||
dir('helm-repo') { | ||
sh """ | ||
helm upgrade --install ${APP_NAME}-staging ${CHART_PATH} \ | ||
--namespace staging \ | ||
-f ${CHART_PATH}/values-staging.yaml \ | ||
--set image.tag=${env.NEW_VERSION} \ | ||
--wait --timeout 5m | ||
""" | ||
|
||
// Verify deployment | ||
def deploymentStatus = sh(script: """ | ||
kubectl rollout status deployment/${APP_NAME}-staging -n staging --timeout=300s | ||
""", returnStatus: true) | ||
|
||
if (deploymentStatus != 0) { | ||
error "Deployment to staging failed" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
steps { | ||
script { | ||
dir('helm-repo') { | ||
def charts = sh(script: "ls charts", returnStdout: true).trim().split() | ||
for (def chart in charts) { | ||
sh """ | ||
helm upgrade --install ${chart}-staging charts/${chart} \ | ||
--namespace staging \ | ||
-f charts/${chart}/values-staging.yaml \ | ||
--wait | ||
""" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
steps { | ||
script { | ||
// Uninstall all Helm releases in the staging namespace | ||
def helmReleases = sh(script: "helm list -n staging -q", returnStdout: true).trim() | ||
if (helmReleases) { | ||
helmReleases.split().each { release -> | ||
sh "helm uninstall ${release} -n staging" | ||
} | ||
} | ||
|
||
// Delete all resources in the staging namespace | ||
sh """ | ||
kubectl delete all --all -n staging | ||
kubectl delete pvc --all -n staging | ||
kubectl delete configmap --all -n staging | ||
kubectl delete secret --all -n staging --ignore-not-found=true | ||
""" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
steps { | ||
echo "Running tests on staging environment..." | ||
// Add your test commands here | ||
} |
Oops, something went wrong.