Discussion:
need to deploy in multiple branches
r***@ithands.biz
2018-11-27 11:57:25 UTC
Permalink
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
}
stage('deploy-production'){
//deploy to production server
sh 'rsync -avz -e ssh --exclude .git
}
stage('mail fail/sucess'){
mail body: 'project build successful',
subject: 'project build successful',
}
}
catch (err) {
currentBuild.result = "FAILURE"
mail body: "project build error is here: ${env.BUILD_URL}" ,
subject: 'project build failed',
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 jenkinsci-users+***@googlegroups.com.
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.
Jan Monterrubio
2018-11-27 13:47:47 UTC
Permalink
You could have a jenkinsfile lube with the repository and check the BRANCH
environment variable to find out where you’re building from.
Post by r***@ithands.biz
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
}
stage('deploy-production'){
//deploy to production server
sh 'rsync -avz -e ssh --exclude .git
}
stage('mail fail/sucess'){
mail body: 'project build successful',
subject: 'project build successful',
}
}
catch (err) {
currentBuild.result = "FAILURE"
mail body: "project build error is here: ${env.BUILD_URL}" ,
subject: 'project build failed',
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
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 jenkinsci-users+***@googlegroups.com.
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.
r***@ithands.biz
2018-11-27 14:01:58 UTC
Permalink
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 jenkinsci-users+***@googlegroups.com.
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.
Jan Monterrubio
2018-11-27 14:10:16 UTC
Permalink
A quick search found this:
https://stackoverflow.com/questions/32789619/jenkins-multibranch-pipeline-what-is-the-branch-name-variable

Once I get to a computer I’ll do some more searching since finding text on
a phone is hard :)
Post by r***@ithands.biz
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
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 jenkinsci-users+***@googlegroups.com.
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.
Jan Monterrubio
2018-11-27 16:19:58 UTC
Permalink
Here's this that might help:
https://jenkins.io/doc/book/pipeline/syntax/#flow-control
Post by Jan Monterrubio
https://stackoverflow.com/questions/32789619/jenkins-multibranch-pipeline-what-is-the-branch-name-variable
Once I get to a computer I’ll do some more searching since finding text on
a phone is hard :)
Post by r***@ithands.biz
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
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 jenkinsci-users+***@googlegroups.com.
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.
Ajay Sharma
2018-11-27 17:53:34 UTC
Permalink
I am also searching, by tomorrow I will reply.
Post by r***@ithands.biz
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
}
stage('deploy-production'){
//deploy to production server
sh 'rsync -avz -e ssh --exclude .git
}
stage('mail fail/sucess'){
mail body: 'project build successful',
subject: 'project build successful',
}
}
catch (err) {
currentBuild.result = "FAILURE"
mail body: "project build error is here: ${env.BUILD_URL}" ,
subject: 'project build failed',
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
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 jenkinsci-users+***@googlegroups.com.
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.
Robert Rajendra
2018-11-28 01:48:02 UTC
Permalink
Thankyou
Post by Ajay Sharma
I am also searching, by tomorrow I will reply.
Post by r***@ithands.biz
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
}
stage('deploy-production'){
//deploy to production server
sh 'rsync -avz -e ssh --exclude .git
}
stage('mail fail/sucess'){
mail body: 'project build successful',
subject: 'project build successful',
}
}
catch (err) {
currentBuild.result = "FAILURE"
mail body: "project build error is here: ${env.BUILD_URL}" ,
subject: 'project build failed',
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
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
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 jenkinsci-users+***@googlegroups.com.
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.
Ajay Sharma
2018-11-28 03:05:01 UTC
Permalink
use this for master only

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

}
Post by Robert Rajendra
Thankyou
Post by Ajay Sharma
I am also searching, by tomorrow I will reply.
Post by r***@ithands.biz
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
}
stage('deploy-production'){
//deploy to production server
sh 'rsync -avz -e ssh --exclude .git
}
stage('mail fail/sucess'){
mail body: 'project build successful',
subject: 'project build successful',
}
}
catch (err) {
currentBuild.result = "FAILURE"
mail body: "project build error is here: ${env.BUILD_URL}" ,
subject: 'project build failed',
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
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
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
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 jenkinsci-users+***@googlegroups.com.
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.
Continue reading on narkive:
Loading...