running docker node in jenkins shared pipeline

13 views
Skip to first unread message

angshuman mahanta

unread,
Jan 27, 2018, 4:21:16 AM1/27/18
to Jenkins Users
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.
Reply all
Reply to author
Forward
0 new messages