Re: need to deploy in multiple branches

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Robert Rajendra


On Tuesday, 27 November 2018 17:25:47 UTC+5:30, [hidden email] wrote:
Hi Team i want to deploy to the staging  only when the code is pushed to staging and to master only  when the code is pushed to master  Please help that what can i do with the script that i made  to achieve that




node{


    currentBuild.result = "SUCCESS"

    try {
            stage('Pull-msater') {
                 // pulling master from the repo
                   git '<a href="https://github.com/raj1rana/mongoDB-docker.git" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fraj1rana%2FmongoDB-docker.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBXukUvn79uW9yuehKPn-EeWjIFA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fraj1rana%2FmongoDB-docker.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBXukUvn79uW9yuehKPn-EeWjIFA&#39;;return true;">https://github.com/raj1rana/mongoDB-docker.git'

                   }
               stage('pull-staging'){
                       //pulling staging from the repo
                    git branch: 'staging', url: '<a href="https://github.com/raj1rana/mongoDB-docker.git" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fraj1rana%2FmongoDB-docker.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBXukUvn79uW9yuehKPn-EeWjIFA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fraj1rana%2FmongoDB-docker.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBXukUvn79uW9yuehKPn-EeWjIFA&#39;;return true;">https://github.com/raj1rana/mongoDB-docker.git'
                   }
               stage('deploy-staging') {
                     //deploy to staging server
                   sh 'rsync -avz  -e ssh --exclude .git /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/Stage/'
                 }
               stage('deploy-production'){
                    //deploy to production server
                   sh 'rsync -avz -e ssh  --exclude .git  /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/master'
                 }
               stage('mail fail/sucess'){
                    mail body: 'project build successful',
                     from: '[hidden email]',
                     replyTo: '[hidden email]',
                     subject: 'project build successful',
                     to: '[hidden email]'
                 }
  
       }
       catch (err) {

        currentBuild.result = "FAILURE"

            mail body: "project build error is here: ${env.BUILD_URL}" ,
            from: '[hidden email]',
            replyTo: '[hidden email]',
            subject: 'project build failed',
            to: '[hidden email]'

        throw err
    }

}
    

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Jan Monterrubio
You could have a jenkinsfile lube with the repository and check the BRANCH environment variable to find out where you’re building from. 

On Tue, Nov 27, 2018 at 05:57 <[hidden email]> wrote:


On Tuesday, 27 November 2018 17:25:47 UTC+5:30, [hidden email] wrote:
Hi Team i want to deploy to the staging  only when the code is pushed to staging and to master only  when the code is pushed to master  Please help that what can i do with the script that i made  to achieve that




node{


    currentBuild.result = "SUCCESS"

    try {
            stage('Pull-msater') {
                 // pulling master from the repo
                   git 'https://github.com/raj1rana/mongoDB-docker.git'

                   }
               stage('pull-staging'){
                       //pulling staging from the repo
                    git branch: 'staging', url: 'https://github.com/raj1rana/mongoDB-docker.git'
                   }
               stage('deploy-staging') {
                     //deploy to staging server
                   sh 'rsync -avz  -e ssh --exclude .git /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/Stage/'
                 }
               stage('deploy-production'){
                    //deploy to production server
                   sh 'rsync -avz -e ssh  --exclude .git  /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/master'
                 }
               stage('mail fail/sucess'){
                    mail body: 'project build successful',
                     from: '[hidden email]',
                     replyTo: '[hidden email]',
                     subject: 'project build successful',
                     to: '[hidden email]'
                 }
  
       }
       catch (err) {

        currentBuild.result = "FAILURE"

            mail body: "project build error is here: ${env.BUILD_URL}" ,
            from: '[hidden email]',
            replyTo: '[hidden email]',
            subject: 'project build failed',
            to: '[hidden email]'

        throw err
    }

}
    

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADgiF9LFW77BQYYC9v31X%2BdGSeTJMAgDCzpi4FhSx%3DERKfiWiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Robert Rajendra
Thanks for reachibg out how do
 I add those variables if there is an article please share

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d8aba17c-076c-4f33-83a0-3c3bae681d64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Jan Monterrubio
A quick search found this: 

Once I get to a computer I’ll do some more searching since finding text on a phone is hard :)

On Tue, Nov 27, 2018 at 08:02 <[hidden email]> wrote:
Thanks for reachibg out how do
 I add those variables if there is an article please share

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d8aba17c-076c-4f33-83a0-3c3bae681d64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADgiF9Lq9WEmvRkyDfDa%2BY98q4tuYkjnUaMUBDwqZS0UEetXyw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Jan Monterrubio

On Tue, Nov 27, 2018 at 8:10 AM Jan Monterrubio <[hidden email]> wrote:
A quick search found this: 

Once I get to a computer I’ll do some more searching since finding text on a phone is hard :)

On Tue, Nov 27, 2018 at 08:02 <[hidden email]> wrote:
Thanks for reachibg out how do
 I add those variables if there is an article please share

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/d8aba17c-076c-4f33-83a0-3c3bae681d64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CADgiF9%2B6Bs4d1aidk3bo4M5gWRSDr-X7JAqdTDsYjkFyjkRbpQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Ajay Sharma
In reply to this post by Robert Rajendra
I am also searching, by tomorrow I will reply.

On Tue 27 Nov, 2018, 5:27 PM <[hidden email] wrote:


On Tuesday, 27 November 2018 17:25:47 UTC+5:30, [hidden email] wrote:
Hi Team i want to deploy to the staging  only when the code is pushed to staging and to master only  when the code is pushed to master  Please help that what can i do with the script that i made  to achieve that




node{


    currentBuild.result = "SUCCESS"

    try {
            stage('Pull-msater') {
                 // pulling master from the repo
                   git 'https://github.com/raj1rana/mongoDB-docker.git'

                   }
               stage('pull-staging'){
                       //pulling staging from the repo
                    git branch: 'staging', url: 'https://github.com/raj1rana/mongoDB-docker.git'
                   }
               stage('deploy-staging') {
                     //deploy to staging server
                   sh 'rsync -avz  -e ssh --exclude .git /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/Stage/'
                 }
               stage('deploy-production'){
                    //deploy to production server
                   sh 'rsync -avz -e ssh  --exclude .git  /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/master'
                 }
               stage('mail fail/sucess'){
                    mail body: 'project build successful',
                     from: '[hidden email]',
                     replyTo: '[hidden email]',
                     subject: 'project build successful',
                     to: '[hidden email]'
                 }
  
       }
       catch (err) {

        currentBuild.result = "FAILURE"

            mail body: "project build error is here: ${env.BUILD_URL}" ,
            from: '[hidden email]',
            replyTo: '[hidden email]',
            subject: 'project build failed',
            to: '[hidden email]'

        throw err
    }

}
    

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAP_NKRn3zsgNDZSUOVw8Sq-YdZA9Xj3pF_UFK_Sa_aLRqajmYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Robert Rajendra
Thankyou 

On Tue, 27 Nov 2018, 11:23 pm Ajay Sharma <[hidden email] wrote:
I am also searching, by tomorrow I will reply.

On Tue 27 Nov, 2018, 5:27 PM <[hidden email] wrote:


On Tuesday, 27 November 2018 17:25:47 UTC+5:30, [hidden email] wrote:
Hi Team i want to deploy to the staging  only when the code is pushed to staging and to master only  when the code is pushed to master  Please help that what can i do with the script that i made  to achieve that




node{


    currentBuild.result = "SUCCESS"

    try {
            stage('Pull-msater') {
                 // pulling master from the repo
                   git 'https://github.com/raj1rana/mongoDB-docker.git'

                   }
               stage('pull-staging'){
                       //pulling staging from the repo
                    git branch: 'staging', url: 'https://github.com/raj1rana/mongoDB-docker.git'
                   }
               stage('deploy-staging') {
                     //deploy to staging server
                   sh 'rsync -avz  -e ssh --exclude .git /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/Stage/'
                 }
               stage('deploy-production'){
                    //deploy to production server
                   sh 'rsync -avz -e ssh  --exclude .git  /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/master'
                 }
               stage('mail fail/sucess'){
                    mail body: 'project build successful',
                     from: '[hidden email]',
                     replyTo: '[hidden email]',
                     subject: 'project build successful',
                     to: '[hidden email]'
                 }
  
       }
       catch (err) {

        currentBuild.result = "FAILURE"

            mail body: "project build error is here: ${env.BUILD_URL}" ,
            from: '[hidden email]',
            replyTo: '[hidden email]',
            subject: 'project build failed',
            to: '[hidden email]'

        throw err
    }

}
    

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAP_NKRn3zsgNDZSUOVw8Sq-YdZA9Xj3pF_UFK_Sa_aLRqajmYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CABbC_KGofVZw2ndwOnGavzEw3S%3DbPcxPxtKcuQaC8pGVJvnGxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: need to deploy in multiple branches

Ajay Sharma
use this for master only

if (!env.CHNAGE_ID && env.BRANCH_NAME == 'master')
{  

  }


On Wed, Nov 28, 2018 at 7:18 AM Robert Rajendra <[hidden email]> wrote:
Thankyou 

On Tue, 27 Nov 2018, 11:23 pm Ajay Sharma <[hidden email] wrote:
I am also searching, by tomorrow I will reply.

On Tue 27 Nov, 2018, 5:27 PM <[hidden email] wrote:


On Tuesday, 27 November 2018 17:25:47 UTC+5:30, [hidden email] wrote:
Hi Team i want to deploy to the staging  only when the code is pushed to staging and to master only  when the code is pushed to master  Please help that what can i do with the script that i made  to achieve that




node{


    currentBuild.result = "SUCCESS"

    try {
            stage('Pull-msater') {
                 // pulling master from the repo
                   git 'https://github.com/raj1rana/mongoDB-docker.git'

                   }
               stage('pull-staging'){
                       //pulling staging from the repo
                    git branch: 'staging', url: 'https://github.com/raj1rana/mongoDB-docker.git'
                   }
               stage('deploy-staging') {
                     //deploy to staging server
                   sh 'rsync -avz  -e ssh --exclude .git /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/Stage/'
                 }
               stage('deploy-production'){
                    //deploy to production server
                   sh 'rsync -avz -e ssh  --exclude .git  /var/lib/jenkins/workspace/pipeline-test/  user@IP:/home/ubuntu/master'
                 }
               stage('mail fail/sucess'){
                    mail body: 'project build successful',
                     from: '[hidden email]',
                     replyTo: '[hidden email]',
                     subject: 'project build successful',
                     to: '[hidden email]'
                 }
  
       }
       catch (err) {

        currentBuild.result = "FAILURE"

            mail body: "project build error is here: ${env.BUILD_URL}" ,
            from: '[hidden email]',
            replyTo: '[hidden email]',
            subject: 'project build failed',
            to: '[hidden email]'

        throw err
    }

}
    

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAP_NKRn3zsgNDZSUOVw8Sq-YdZA9Xj3pF_UFK_Sa_aLRqajmYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CABbC_KGofVZw2ndwOnGavzEw3S%3DbPcxPxtKcuQaC8pGVJvnGxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAP_NKRnVv9FiQ1mQi9ZRa%3D8XmbPdpWrShq7NChoo60oCmSN9Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.