Hello! I'm trying to publish my consumer contract ...
# pact-js
l
Hello! I'm trying to publish my consumer contract to PactFlow by using
publishPacts(opts)
function from Jenkins, but it fails with next error:
Copy code
13:01:19  Error publishing pacts: Error: Pact publication failed with non-zero exit code. Full output was:
13:01:19  /home/jenkins/agent/workspace/<my_repo>/node_modules/@pact-foundation/pact-node/standalone/linux-x64-2.4.1/pact/lib/ruby/bin/ruby: 6: eval: -: not found
13:01:19  
13:01:19      at ChildProcess.<anonymous> (/home/jenkins/agent/workspace/<my_repo>/node_modules/@pact-foundation/pact-node/src/publisher.js:79:40)
13:01:19      at Object.onceWrapper (node:events:634:26)
13:01:19      at ChildProcess.emit (node:events:531:35)
13:01:19      at maybeClose (node:internal/child_process:1105:16)
13:01:19      at Socket.<anonymous> (node:internal/child_process:457:11)
13:01:19      at Socket.emit (node:events:519:28)
13:01:19      at Pipe.<anonymous> (node:net:339:12)
13:01:19  [14:01:19.523] INFO (698): pact-node@10.18.0: Publishing Pacts to Broker
13:01:19  [14:01:19.524] INFO (698): pact-node@10.18.0: Publishing pacts to broker at: https://<my_domain>.<http://pactflow.io/|pactflow.io/>
13:01:19  [14:01:19.536] WARN (698): pact-node@10.18.0: Pact exited with code 127.
13:01:19  [14:01:19.536] ERROR (698): pact-node@10.18.0: Pact publication failed with non-zero exit code. Full output was:
13:01:19  /home/jenkins/agent/workspace/<my_repo>/node_modules/@pact-foundation/pact-node/standalone/linux-x64-2.4.1/pact/lib/ruby/bin/ruby: 6: eval: -: not found
When I run it from my local machine it works fine and with no issues, but when I try to run it from a Debian Docker container in Jenkins I get the above error. I guess there may be some additional dependencies that my linux container is missing. Is there any list of all the requirements and dependencies needed to run the publishPacts() function with no errors?
m
I can’t quite understand the error. It looks like perhaps it can’t find
eval
, or eval is executing and it’s not happen with some argument
OK so my guess is
<my repo>
has a
-
in it. The contents of the
ruby
“binary” is thus:
Copy code
#!/bin/bash
set -e
ROOT=`dirname "$0"`
ROOT=`cd "$ROOT/.." && pwd`
eval "`\"$ROOT/bin/ruby_environment\"`"
exec "$ROOT/bin.real/ruby" "$@"
/opt/pact/lib/ruby/bin/ruby
I suspect
eval
isn’t happy with that?
l
That is right @Matt (pactflow.io / pact-js / pact-go), there are 2
-
in <my_repo>, which is the Job name in Jenkins
The Job name is as follows
my-github-repo - PRB - Contract Test
So, I will rename the Job and remove the
-
and try again
Do you think the spaces in the job name may also cause issues?
Yes, the spaces were the cause of the error, I renamed the job and removed all the spaces and now I'm able to publish the contract to PactFlow 😃
🙌 1
Thanks!
m
aha! That’s a bit annoying we don’t support spaces, if you can hack the
ruby
file (which is just a bash or
sh
script) to work with spaces, we could look to add a PR to https://phusion.github.io/traveling-ruby/ which is the tool we use to package up the CLI