Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
akinolafusi committed Mar 14, 2022
1 parent 856f155 commit ffe95fd
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 130 deletions.
154 changes: 24 additions & 130 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,145 +1,39 @@
pipeline {
agent any

environment
{
PROJECT = 'zooto-tooling-prod'
ECRURL = '059636857273.dkr.ecr.eu-central-1.amazonaws.com'
DEPLOY_TO = 'development'
}

stages {

stage("Initial cleanup") {
steps {
dir("${WORKSPACE}") {
deleteDir()
stage('Build') {
parallel {
stage('Build') {
steps {
build 'Build'
}
}
}
}

stage('Checkout')
{
steps {
checkout([
$class: 'GitSCM',
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
// branches: [[name: '$branch']],
userRemoteConfigs: [[url: "https://github.com/darey-io/tooling.git ",credentialsId:'GITHUB_CREDENTIALS']]
])

}
stage('Message') {
steps {
echo 'First Build Done'
}
}

// stage('Checkout Helm chart')
// {
// steps {
// checkout([
// $class: 'GitSCM',
// doGenerateSubmoduleConfigurations: false,
// extensions: [[$class: 'RelativeTargetDirectory',
// relativeTargetDir: 'helm']],
// submoduleCfg: [],
// branches: [[name: 'master']],
// userRemoteConfigs: [[url: "https://gitlab.com/propitix/kubernetes/helm.git",credentialsId:'GIT_CREDENTIALS']]
// ])

// }
// }
stage('Build preparations')
{
steps
{
script
{
// calculate GIT lastest commit short-hash
gitCommitHash = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
shortCommitHash = gitCommitHash.take(7)
// calculate a sample version tag
VERSION = shortCommitHash
// set the build display name
currentBuild.displayName = "#${BUILD_ID}-${VERSION}"
IMAGE = "$PROJECT:$VERSION"
}
}
}

stage('Build For Dev Environment') {
when {
expression { BRANCH_NAME ==~ /(dev)/ }
}
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("dev-$BUILD_NUMBER")
}
}
}
}

stage('Build For Staging Environment') {
when {
expression { BRANCH_NAME ==~ /(staging|master)/ }
}
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("staging-$BUILD_NUMBER")
}
}
}
}


stage('Build For Production Environment') {
when { tag "release-*" }
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("prod-$BUILD_NUMBER")
}
}
stage('Post Build') {
parallel {
stage('Post Build') {
steps {
archiveArtifacts '**'
}
}
}

//







stage('Messgae') {
steps {
echo 'Archiving done'
}
}

// stage('Update Helm appVersion') {
// steps {
// echo 'Update appVersion'
// sh '''
// cat helm/Chart.yaml.template | sed "s/appVersion: .*/appVersion: \"${BUILD_NUMBER}\"/g" > helm/Chart.yaml
// '''
// }
// }
}
}

post
{
always
{
sh "docker rmi -f $IMAGE "
}
}
}
}
}
145 changes: 145 additions & 0 deletions Jenkinsfileddddd
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
pipeline {
agent any

environment
{
PROJECT = 'zooto-tooling-prod'
ECRURL = '059636857273.dkr.ecr.eu-central-1.amazonaws.com'
DEPLOY_TO = 'development'
}

stages {

stage("Initial cleanup") {
steps {
dir("${WORKSPACE}") {
deleteDir()
}
}
}

stage('Checkout')
{
steps {
checkout([
$class: 'GitSCM',
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
// branches: [[name: '$branch']],
userRemoteConfigs: [[url: "https://github.com/darey-io/tooling.git ",credentialsId:'GITHUB_CREDENTIALS']]
])

}
}

// stage('Checkout Helm chart')
// {
// steps {
// checkout([
// $class: 'GitSCM',
// doGenerateSubmoduleConfigurations: false,
// extensions: [[$class: 'RelativeTargetDirectory',
// relativeTargetDir: 'helm']],
// submoduleCfg: [],
// branches: [[name: 'master']],
// userRemoteConfigs: [[url: "https://gitlab.com/propitix/kubernetes/helm.git",credentialsId:'GIT_CREDENTIALS']]
// ])

// }
// }
stage('Build preparations')
{
steps
{
script
{
// calculate GIT lastest commit short-hash
gitCommitHash = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
shortCommitHash = gitCommitHash.take(7)
// calculate a sample version tag
VERSION = shortCommitHash
// set the build display name
currentBuild.displayName = "#${BUILD_ID}-${VERSION}"
IMAGE = "$PROJECT:$VERSION"
}
}
}

stage('Build For Dev Environment') {
when {
expression { BRANCH_NAME ==~ /(dev)/ }
}
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("dev-$BUILD_NUMBER")
}
}
}
}

stage('Build For Staging Environment') {
when {
expression { BRANCH_NAME ==~ /(staging|master)/ }
}
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("staging-$BUILD_NUMBER")
}
}
}
}


stage('Build For Production Environment') {
when { tag "release-*" }
steps {
echo 'Build Dockerfile....'
script {
sh("eval \$(aws ecr get-login --no-include-email --region eu-central-1 | sed 's|https://||')")
// sh "docker build --network=host -t $IMAGE -f deploy/docker/Dockerfile ."
sh "docker build --network=host -t $IMAGE ."
docker.withRegistry("https://$ECRURL"){
docker.image("$IMAGE").push("prod-$BUILD_NUMBER")
}
}
}
}

//








// stage('Update Helm appVersion') {
// steps {
// echo 'Update appVersion'
// sh '''
// cat helm/Chart.yaml.template | sed "s/appVersion: .*/appVersion: \"${BUILD_NUMBER}\"/g" > helm/Chart.yaml
// '''
// }
// }
}

post
{
always
{
sh "docker rmi -f $IMAGE "
}
}
}

0 comments on commit ffe95fd

Please sign in to comment.