使用docker在Jenkins中运行多个sidecars

时间:2018-06-04 12:25:33

标签: docker jenkins jenkins-pipeline

我正在运行如下的mysql边车:

docker.image("mysql:5.6").withRun("-e MYSQL_ALLOW_EMPTY_PASSWORD=yes -e", '--lower_case_table_names=1') { c ->
  docker.image("mysql:5.6").inside("--link ${c.id}:mysql") {

    /* Wait until MySQL service is up */
    sh "while ! mysqladmin ping -u root -h mysql -p ; do sleep 1; done"
    sh "mysql -u root -h mysql -p --batch -e 'show databases;'"
  }
  dockerRunArgs.add("--link ${c.id}:mysql")

  docker.build(image, dockerBuildArgs.join(' ')).inside(dockerRunArgs.join(' ')) {

    // the actual building, archiving, deployment, etc, stages go here
      withCredentials([string(credentialsId: 'CREDENTIALID', variable: 'VARIABLE')]) {
        stage('Build') {
          sh 'chmod 777 ./build.sh'
          sh "./build.sh"
        }
        stage('DB migrations checkout ') {
          checkout([
            $class: 'GitSCM',
            branches: [[name: 'develop']],
            userRemoteConfigs: [[
              credentialsId: 'TOKEN',
              url: 'mygithuburl.git'
            ]]
          ])

          sh 'composer install --prefer-dist --no-interaction --no-dev --no-progress'
          sh 'php artisan migrate:refresh --seed'
        }

      }
  } 
}

这是Jenkins文档中所示。现在我需要运行一些其他服务,如Redis, Elasticsearch, Memcached and Beanstalkd。那么我需要添加这些docker图像呢?

现在我正在MySQL泊坞窗图片中构建泊坞窗图像。是否可以在一个阶段中运行每个集装箱侧车,然后进行迁移并在下一阶段运行测试?

0 个答案:

没有答案