PostgreSQL 9.3 failing on createuser in Travis - postgresql

This behavior from Travis CI is new:
$ sudo -u postgres createuser -p 5432 travis &>/dev/null
Shall the new role be a superuser? (y/n)
The build dies before going any further, because it’s waiting for user input that it will never get. My Travis config looks like this, with the 9.3 addon specified. Build 72615655 is a sample failure, while build 72408935 is a successful build from two days ago with an identical Travis configuration.

I got same issue in Travis CI for PostgreSQL.
By adding sudo: false solved the issue.
my .travis.yml
addons:
postgresql: "9.4"
sudo: false

Travis reports that this has been fixed: https://github.com/travis-ci/travis-ci/issues/4584

Related

How to run PostgreSQL after install on a clean Ubuntu build?

I've just installed Ubuntu, installed Conda, several packages including Django and PostgreSQL via Conda (with Conda installed PostgreSQL). That's it, nothing else.
I'm trying to follow the instructions here: https://github.com/rdkit/OCEAN. Rather than creating a virtual environment I've created a Conda one instead. I'm not sure if that's going to make any difference.
Also please note: this is a clean build. I have not activated anything or created any DB user etc. All I've done is activate the Conda env of choice and started installing the packages listed on the link above.
I'm having problems with the initial PostgreSQL instructions recreated here...
Get a clone of OCEAN from the Repo:
git clone https://www.github.com/rdkit/OCEAN.git
cd OCEAN
Create a PostgreSQL-User, the database for OCEAN and fill the OCEAN-DB:
# create PostgreSQL-User for OCEAN
# password 'ocean_pw' should be used when asked,
# according to database-entry in settings.py
createuser -P -s -d -r -e ocean_user
# create PostgreSQL-Database for OCEAN
createdb --owner=ocean_user ocean
When I try createuser -P -s -d -r -e ocean_user and then add the required password (in the Git link) I get the error:
createuser: error: could not connect to database postgres: could not connect to server: No such file or directory. Is the server running locally or accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I have a Conda environment and on a very clean Ubuntu machine. The last time I touched a DB was years ago. How can I resolve this?

Run postgres query in jenkins after build

I installed jenkins and postgres on same centos7 server.
I also installed and configured "database" and "PostgreSQL Database Plugin" as shown in this image:
I want to insert data in my database jenkinsdb (the table i want to work on is "builds") after build is succesfull so i can track history of builds , deployments etc.
How can i run query to my database from jenkins ?
Create a script file, let's say build_complete.sh, with the postgresql commands:
#!/bin/bash
#Updated command that solves the bug. Courtesy: YoussefBoudaya's comment.
"export PGPASSWORD='postgres'; sudo -u postgres -H -- psql -d jenkinsdb -c "SELECT * FROM builds" postgres"
Please confirm psql path from server, it will be similar to /usr/lib/postgresql/10/bin/psql.
Add execute script step at the end of your pipeline and simple run your script.
A similar solution can be read here.

How to reset the DB on each deployment on heroku?

So currently I'm working on a project on Heroku with Drupal and my issue is that I want to reset the database each time I deploy to master, yes I know it not ideal but its a development env because I'm working Drupal plugin and it would be nice if changes happened it could just reset to a state.
But when I try to connect using psql and some variables I just get password authentication failed for user even tho I know its the right password because I got it from Heroku itself.
Currently, I have tried using the console to try to make in connection soi could run a DROP TABLE command for me to afterword import an SQL file with the basic setup using pg_dump, and put it into a .sh script and run it with and release: in a procfile
Until now I have this as a release.sh file where I only tried in the console on heroku
PGHOST=HOST PGPORT=5432 \
PGDATABASE=DB \
PGUSER=USER PGPASSWORD=SOMEPASS \
psql
Try below command to reset DB
heroku pg:reset DATABASE_URL

django test in travis CI

I have a django project using travis CI
when I check pep8 in travis CI
It has no problem
and I want testing functional_test in travis CI
I insert the code in .travis.yml
In .travis.yml(hggg is a role name in my django project database)
language: python
python:
- "3.5.1"
install:
- pip install -r requirement/development.txt
before_script:
- createuser hggg
# # command to run tests
script:
- pep8
- python wef/manage.py test functional_test
but when build start
travis server can't create database
The command "pep8" exited with 0.
$ python wef/manage.py test users
Creating test database for alias 'default'...
Got an error creating the test database: permission denied to create database
Type 'yes' if you would like to try deleting the test database 'test_bookconnect', or 'no' to cancel:
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated
I want create a database(postgresql) in trvis CI
Please give me some advise

Can't clone public repo from within Dockerfile

I have the following line in my Dockerfile:
RUN git clone https://github.com/assafg/youtube-remote.git ./youtube-remote
When executing sudo docker build -t 'yremote' .
I get the following error:
Cloning into './youtube-remote'... fatal: unable to access
'https://github.com/assafg/youtube-remote.git/': Could not resolve
host: github.com The command '/bin/sh -c git clone
https://github.com/assafg/youtube-remote.git ./youtube-remote'
returned a non-zero code: 128
Running clone command from command line works fine.
This can happen if your container can't connect to the internet. Possibly because it was started with a weird networking option? Run this command to check default internet connectivity:
docker run ubuntu apt install -y git && \
git clone https://github.com/assafg/youtube-remote.git ./youtube-remote
If that container successfully pulls down the repo, it probably means the first container has a networking problem. Try to restart, or change networking settings.
Docker Network just became a first class citizen in the Docker ecosystem. It's a really fast-moving project. This advice applies to v1.8
This is not a very scientific answer but sometimes docker restart helps especially in cases connected with docker network.