running docker node in jenkins shared pipeline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

running docker node in jenkins shared pipeline

angshuman mahanta
Hi, I am new to Jenkins, Need a help wrt a scenario. I have to configure jenkins shared pipeline.

my current jenkinsfile somethhing like looks like -

stage('npm docker build'){
            sh 'docker pull xxx.net/xxx/xxx'
            sh 'chmod -R 777 .'                
            docker_node = docker.build('xxx.net/xxx/xxx')
        }

        stage('npm install'){
                    docker_node.inside('') {  
                        sh 'npm install'
                    }
        }
        stage('Do something'){
                    docker_node.inside('') {  
                       Do something
                    }
        }

         stage('Do something'){
            docker_node.inside(''){
                Do something
              }
         }  

         stage('Next stage'){
             
              docker_node.inside(''){     
               
            }
 
             
         }

         stage('Test'){
            def test= docker.image('xxx.net/xxx/xxx')
            test.inside(''){
               run my test
            }
        }


I want move the execution of all the stages to shared pipeline. But as you all the execution happening inside the docker node which is built at the first stage, and executing the next stages inside docker node..
How can I pass the docker node reference to subsequent stages.

--
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/d6920fab-01b2-417c-b650-1b493b445d3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.