Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46336

Sidecar docker containers for declarative

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      The "sidecar container" pattern is a popular one for setting up dependent containers for running tests/builds. 

       

      It would be nice to have support for this pattern in declarative to avoid the need to drop to script. 

       

      To investigate...

       

      In scope: 

      testing: 

      • Should be able to be fully automated using ci.jenkins.io 
      • check sidecar containers are shut down in all scenarios possible

        Attachments

          Issue Links

            Activity

            Hide
            orrc Christopher Orr added a comment -

            Duplicate of JENKINS-41581?

            Show
            orrc Christopher Orr added a comment - Duplicate of  JENKINS-41581 ?
            Hide
            jamesdumay James Dumay added a comment -

            Christopher Orr good eye Thank you!

            Show
            jamesdumay James Dumay added a comment - Christopher Orr good eye Thank you!
            Hide
            csanchez Carlos Sanchez added a comment -

            There is an implementation for Kubernetes in review at https://github.com/jenkinsci/kubernetes-plugin/pull/306 (JENKINS-48135)

            Show
            csanchez Carlos Sanchez added a comment - There is an implementation for Kubernetes in review at https://github.com/jenkinsci/kubernetes-plugin/pull/306 ( JENKINS-48135 )
            Hide
            csanchez Carlos Sanchez added a comment -

            kubernetes plugin now supports Pods in declarative, using yaml definition

            Show
            csanchez Carlos Sanchez added a comment - kubernetes plugin now supports Pods in declarative, using yaml definition
            Hide
            davidvanlaatum David van Laatum added a comment -

            Here is a way of doing it until proper support is added

                stages {
                    stage('Run Tests') {
                        parallel {
                            stage("RSpec") {
                              agent { label 'docker' }
                              steps {
                                script {
                                  docker.image('postgres').withRun('-e POSTGRES_DB=xxxx_test') { container ->
                                    docker.build('netadmin-jenkins',' --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --build-arg no_proxy=$no_proxy -f Dockerfile.jenkins --pull .').inside("--link=${container.id}:postgres -e DATABASE_URL=postgresql://postgres:postgres@postgres:5432/xxxx_test") {
                                      withEnv(['DATABASE_URL=postgres://postgres@postgres:5432/','PGHOST=postgres','PGUSER=postgres','RAILS_ENV=test']) {
                                          sh 'yarn install'
                                          rake 'db:create'
                                          rake 'db:migrate'
                                          rake 'db:seed'
                                          rake 'spec'
                                      }
                                    }
                                  }
                                }
                              }
                              post {
                                  always {
                                      junit '**/reports/*.xml'
                                  }
                              }
                            }
                            stage("RuboCop") {
                                agent {
                                    dockerfile {
                                      additionalBuildArgs '--pull --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --build-arg no_proxy=$no_proxy'
                                      filename 'Dockerfile.jenkins'
                                    }
                                }
                                steps {
                                    rake 'rubocop | tee rubocop.log'
                                }
                                post {
                                    always {
                                        warnings canResolveRelativePaths: false, failedTotalHigh: '0', healthy: '0', parserConfigurations: [[parserName: 'RuboCop', pattern: 'rubocop.log']], unHealthy: '100', unstableTotalAll: '0'
                                    }
                                }
                            }
            
            Show
            davidvanlaatum David van Laatum added a comment - Here is a way of doing it until proper support is added stages { stage( 'Run Tests' ) { parallel { stage( "RSpec" ) { agent { label 'docker' } steps { script { docker.image( 'postgres' ).withRun( '-e POSTGRES_DB=xxxx_test' ) { container -> docker.build( 'netadmin-jenkins' , ' --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --build-arg no_proxy=$no_proxy -f Dockerfile.jenkins --pull .' ).inside( "--link=${container.id}:postgres -e DATABASE_URL=postgresql: //postgres:postgres@postgres:5432/xxxx_test" ) { withEnv([ 'DATABASE_URL=postgres: //postgres@postgres:5432/' , 'PGHOST=postgres' , 'PGUSER=postgres' , 'RAILS_ENV=test' ]) { sh 'yarn install' rake 'db:create' rake 'db:migrate' rake 'db:seed' rake 'spec' } } } } } post { always { junit '**/reports/*.xml' } } } stage( "RuboCop" ) { agent { dockerfile { additionalBuildArgs '--pull --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --build-arg no_proxy=$no_proxy' filename 'Dockerfile.jenkins' } } steps { rake 'rubocop | tee rubocop.log' } post { always { warnings canResolveRelativePaths: false , failedTotalHigh: '0' , healthy: '0' , parserConfigurations: [[parserName: 'RuboCop' , pattern: 'rubocop.log' ]], unHealthy: '100' , unstableTotalAll: '0' } } }

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              michaelneale Michael Neale
              Votes:
              29 Vote for this issue
              Watchers:
              44 Start watching this issue

                Dates

                Created:
                Updated: