use this for master only
if (!env.CHNAGE_ID && env.BRANCH_NAME == 'master')
{
}
On Wed, Nov 28, 2018 at 7:18 AM Robert Rajendra <[email protected]>
wrote:
> Thankyou
>
> On Tue, 27 Nov 2018, 11:23 pm Ajay Sharma <[email protected] wrote:
>
>> I am also searching, by tomorrow I will reply.
>>
>> On Tue 27 Nov, 2018, 5:27 PM <[email protected] wrote:
>>
>>>
>>>
>>> On Tuesday, 27 November 2018 17:25:47 UTC+5:30, [email protected]
>>> 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: '[email protected]',
>>>> replyTo: '[email protected]',
>>>> subject: 'project build successful',
>>>> to: '[email protected]'
>>>> }
>>>>
>>>> }
>>>> catch (err) {
>>>>
>>>> currentBuild.result = "FAILURE"
>>>>
>>>> mail body: "project build error is here: ${env.BUILD_URL}" ,
>>>> from: '[email protected]',
>>>> replyTo: '[email protected]',
>>>> subject: 'project build failed',
>>>> to: '[email protected]'
>>>>
>>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/9a3e3b37-0da7-467e-8f05-ecb7458bcf7e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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 [email protected].
>> 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
>> <https://groups.google.com/d/msgid/jenkinsci-users/CAP_NKRn3zsgNDZSUOVw8Sq-YdZA9Xj3pF_UFK_Sa_aLRqajmYA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-users/CABbC_KGofVZw2ndwOnGavzEw3S%3DbPcxPxtKcuQaC8pGVJvnGxQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CABbC_KGofVZw2ndwOnGavzEw3S%3DbPcxPxtKcuQaC8pGVJvnGxQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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 [email protected].
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.