0

Ich bin im Prozess der Migration von CircleCi 1.0 zu CircleCi 2.0. Hier ist, wie meine circle.yml Dateien wie folgt aussehen:Verwenden Sie den Befehl psql in CircleCi 2.0 Build

version: 2 
environment: 
    TZ: "/usr/share/zoneinfo/America/Los_Angeles" 

jobs: 
    build: 
    working_directory: ~/circleci-dashboard 
    docker: 
     - image: circleci/ruby:2.3-node 
     environment: 
      PGHOST: 127.0.0.1 
      PGUSER: ubuntu 
      RAILS_ENV: test 
     - image: circleci/postgres:9.6-alpine 
     environment: 
      POSTGRES_USER: ubuntu 
      POSTGRES_DB: circle_test 
      POSTGRES_PASSWORD: "" 
    steps: 
     - checkout 

     - run: 
      name: 'CircleCI dependencies' 
      command: bash deploy/circle-dependencies.sh 

     # Restore bundle cache 
     - type: cache-restore 
     key: dashboard-{{ checksum "Gemfile.lock" }} 

     # Bundle install dependencies 
     - run: bundle install --path vendor/bundle 

     # Store bundle cache 
     - type: cache-save 
     key: dashboard-{{ checksum "Gemfile.lock" }} 
     paths: 
      - vendor/bundle 

     # Add the Postgres 9.6 binaries to the path. 
     - run: echo '/usr/lib/postgresql/9.6/bin/:$PATH' >> $BASH_ENV 

     - run: sudo apt install postgresql-client 

     - run: 
      name: Set up Survey Builder database 
      command: sudo psql -p 5433 -c 'create database survey_builder_test' 

     - run: 
      name: Set up database 
      command: | 
      bundle exec rake db:create db:schema:load --trace 
      environment: 
      DATABASE_URL: "postgres://[email protected]:5432/circle_test" 

Ich habe ein Problem mit diesem Befehl:

- run: 
     name: Set up Survey Builder database 
     command: sudo psql -p 5432 -c 'create database survey_builder_test' 

und es gibt folgende Fehlermeldung:

#!/bin/bash -eo pipefail 
sudo psql -p 5432 -c 'create database survey_builder_test' 

psql: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? 
Exited with code 2 

Irgendwelche Hinweise sind willkommen ?

+0

Hat die Antwort für Sie funktioniert? – Gerep

+0

Ich werde das heute überprüfen und Sie wissen lassen. –

Antwort

0

Der Befehl sudo psql -p 5433 -c 'create database survey_builder_test'circleci/ruby:2.3-node auf das Bild ausgeführt wird, das ist, warum es notwendig war postgresql-client zu installieren, aber es ist auch für die Postgres Dienst warten, für den Start erforderlich und für, ich bin mit diesem:

- run: 
      name: Waiting for PostgreSQL to start 
      command: | 
      for i in `seq 1 10`; 
      do 
       nc -z localhost 5432 && echo Success && exit 0 
       echo -n . 
       sleep 2 
      done 
      echo Failed waiting for Postgres && exit 1 
Verwandte Themen