2017-10-26 15 views
-2

私はジェンキンでパイプラインプロジェクトを作ろうとしています。 と私は/ PHP-yii2、MySQLをdmstr必要がありますのための5つの容器は、私のアプリmysqlとphpドッカーのコンテナを使ってジェンキンスパイプラインを作成するには

 
    node('lm.backend.test') { 
      checkout scm 
     docker.image('mysql:5').withRun('-e "MYSQL_ROOT_PASSWORD=my-secret-pw"'){ c -> 
      docker.image('mysql:5').inside("--link ${c.id}:db") { 
       sh 'service mysql start' 
      } 
      docker.image('dmstr/php-yii2').inside("--link ${c.id}:db") { 
       sh 'php -v' 
       sh 'mysql -v' 

       stage('Build') { 
        sh 'cd basic && composer dump-autoload && composer clear-cache && composer install' 
        } 
       stage('TEST API'){ 
        sh 'cd basic && vendor/bin/codecept build && vendor/bin/codecept run' 
       } 
      } 
     } 
     stage('Deploy'){ 
      echo 'Deploying....' 
     } 
    } 

結果

 
    + docker run -d -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:5 
    Unable to find image 'mysql:5' locally 
    5: Pulling from library/mysql 
    85b1f47fba49: Pulling fs layer 
    27dc53f13a11: Pulling fs layer 
    095c8ae4182d: Pulling fs layer 
    ... 
    Status: Downloaded newer image for mysql:5 
    ... 
    + service mysql start 
    2017-10-26T13:13:19.717210Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
    2017-10-26T13:13:20.596078Z 0 [Warning] InnoDB: New log files created, LSN=45790 
    2017-10-26T13:13:20.784780Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 
    2017-10-26T13:13:20.867922Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7061064d-ba4f-11e7-8f0f-0242ac110003. 
    2017-10-26T13:13:20.874019Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 
    2017-10-26T13:13:20.884048Z 1 [Warning] [email protected] is created with an empty password ! Please consider switching off the --initialize-insecure option. 
    2017-10-26T13:13:22.427363Z 1 [Warning] 'user' entry '[email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427401Z 1 [Warning] 'user' entry '[email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427411Z 1 [Warning] 'user' entry '[email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427428Z 1 [Warning] 'db' entry 'performance_schema [email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427435Z 1 [Warning] 'db' entry 'sys [email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427445Z 1 [Warning] 'proxies_priv' entry '@ [email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427480Z 1 [Warning] 'tables_priv' entry 'user [email protected]' ignored in --skip-name-resolve mode. 
    2017-10-26T13:13:22.427490Z 1 [Warning] 'tables_priv' entry 'sys_config [email protected]' ignored in --skip-name-resolve mode. 
    ... 
    $ docker stop --time=1 b4a8a716f4aa142b142a458b7ef5b26a241b0afb8c0ad60440558e64a4f8393f 
    $ docker rm -f b4a8a716f4aa142b142a458b7ef5b26a241b0afb8c0ad60440558e64a4f8393f 
    [Pipeline] // withDockerContainer 
    [Pipeline] sh 
    [live-monitors-control_new-CALN2TMKEXYXFJOAARVVINY7KIIEDLY2MJOL4IZEPHIXNJTTWPXA] Running shell script 
    + docker stop e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d 
    e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d 
    + docker rm -f e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d 
    e59fc8bfc4d6a9214b90dbc7a0c8ba0915cf0f05b0799e36cbc986fe792d904d 
    [Pipeline] } 
    [Pipeline] // node 
    [Pipeline] End of Pipeline 
    ERROR: script returned exit code -1 
    Finished: FAILURE 
+0

あなたはあなたの質問を質問として言い換えることができますか?あなたはこれまで何をしようとしましたか?どのように失敗しましたか? –

+0

どのように最初のコンテナが十分でないmysqlよりも、私はドッカーで自分のアプリケーションを実行できます。私は2つのコンテナを横に並びたい。そして、2番目のコンテナからデータベースにアクセスする –

+0

mysqlとphpの両方を含む単一のコンテナを作成するか、コンテナをコンテナ内で実行したいのですか? –

答えて

0

を実行しますが、mysqlの容器内のphpコンテナを実行しようとしている場合は、あなたが試すことができますドッカーのソックスをmysqlコンテナの中にマウントします。

mysqlimage.inside('-v /var/run/docker.sock:/var/run/docker.sock') 
    { 
      phpimage.inside() 
      { 
      .......... 
      } 
    } 

私はこれを試したことはありませんが、動作する可能性があります。

関連する問題