2

I've been handed a project from a coworker with zero knowledge of Postgres. I'm trying to integrate a pg_restore into a Jenkins Pipeline job and it returns one error that I have been told is fine to overlook. However, this error obviously causes the Jenkins job to fail, which is unideal.

Is there a way to mitigate or stifle the output of this one error, without stopping any other (more serious) errors from being recorded?

The command I am running (with all personal data stripped) is

PGPASSWORD="password" pg_restore -h path -U user -d database filename -F c -c

and it returns this error (but executes successfully)

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 8290; 0 0 COMMENT EXTENSION plpgsql 
pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of extension plpgsql
    Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

Again, I have less than zero Postgres experience. Is there an easy way to ignore this one error, or is this just something I need to live with?

Alex
  • 2,555
  • 6
  • 30
  • 48
  • Possible duplicate of [How to solve privileges issues when restore PostgreSQL Database](https://stackoverflow.com/questions/13410631/how-to-solve-privileges-issues-when-restore-postgresql-database) – dmfay May 22 '17 at 19:37
  • @dmfay While you may be right from a postgres approach, I'm not trying to solve the underlying problem so much as suppress the error. I don't have access to the database this is contacting so the only things I can edit are the jenkins job and the commands I'm running. – Alex May 22 '17 at 19:40

1 Answers1

1

If you run pg_restore as the user who owns the extension in the source database, that would fix the problem for real.

For just suppressing the issue: with old-style script steps, adding #!/bin/sh -x as the first line would prevent it from aborting on a non-zero return code (Jenkins normally runs shells with the -e option as well). It's worth a shot with a pipeline build but I don't know for sure if it'll work the same way. If it does, do be aware that the script will continue after other bad return codes as well.

dmfay
  • 2,417
  • 1
  • 11
  • 22