Hi,

I just created jenkinsfile for deploy sample application to my k8s, but the 
deployment always build "dev" image and deploy to dev namespace in k8s. i 
tried to commit in master branch but still build "dev" image dan deploy to 
"dev" namespace in k8s.

Please advice... whats wrong with my pipeline, fyi... i create the job in 
jenkins with "freestyle".

pipeline {
>     agent any
>     environment {
>         project_id = 'kurusetra'
>         app_name = 'nginx-hello'
>     }
>
>     stages {
>
>         stage('Clone Repository') {
>             steps {
>                 checkout scm
>             }
>         }
>
>         stage('Build Docker Images') {
>             steps {
>                 script {
>                     if (env.BRANCH_NAME == 'origin/master') {
>                         myapp = 
> docker.build("${project_id}/${app_name}-prod:${env.BUILD_NUMBER}")
>                     } else {
>                         myapp = 
> docker.build("${project_id}/${app_name}-dev:${env.BUILD_NUMBER}")
>                     }
>                 }
>             }
>         }
>
>         stage('Push Images') {
>             steps {
>                 script {
>                     
> docker.withRegistry('https://docker.xxx.com/kurusetra', 'harbor') {
>                         myapp.push("${env.BUILD_NUMBER}")
>                         myapp.push("latest")
>                     }
>                 }
>             }
>         }
>
>         stage('Deploy to K8s') {
>             steps {
>                 script {
>                     if (env.BRANCH_NAME == 'origin/master') {
>                         sh "sed -i 
> 's/${app_name}:latest/${app_name}-prod:${env.BUILD_NUMBER}/g' 
> deployment.yaml"
>                         sh 'kubectl apply -f ./deployment.yaml -n prod'
>                     } else {
>                         sh "sed -i 
> 's/${app_name}:latest/${app_name}-dev:${env.BUILD_NUMBER}/g' 
> deployment.yaml"
>                         sh 'kubectl apply -f ./deployment.yaml -n dev'
>                     }
>                 }
>             }
>         }
>     }
> }
>


Thanks
Kurusetra 

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/34777fd2-93aa-4feb-8f34-6fc4ff631058%40googlegroups.com.

Reply via email to