Hi All, when I tried to run pact tests in Jenkins ...
# pact-go
s
Hi All, when I tried to run pact tests in Jenkins machine after all Go dependencies, it is throwing below error? has anyone faced it?
Copy code
14:05:57  2023/06/06 13:05:57 [INFO] checking pact-broker within range >= 1.22.3
14:05:57  2023/06/06 13:05:57 [ERROR] CLI tools are out of date, please upgrade before continuing
y
Have you download the pact cli tools and made them available on your path
s
hi Yousaf, yes, below is what I have put in Makefile
install:
@if [ ! -d pact/bin ]; then\
echo "--- 🐿 Installing Pact CLI dependencies"; \
curl -fsSL <https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh> | bash -x; \
fi
Copy code
14:53:42  + make install test-unit
14:53:42  --- ���� Installing Pact CLI dependencies
Copy code
14:53:59  === RUN   TestHandler_ModelMandatoryCheck
14:53:59  2023/06/06 13:53:59 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0
14:53:59  2023/06/06 13:53:59 [ERROR] CLI tools are out of date, please upgrade before continuing
y
is it available on the path tho? is you echo $PATH, you should have a entry that points to
pact/bin
folder wherever it is located
ie can you run
pact-mock-service --help
or do you need to specify the full path to the executable, pact-go expects the tools to be on the
PATH
as per the docs. You could also try v2 which uses the pact-rust core via the FFI library instead, and doesn't need to download the CLI tools, but I believe adding to your path should resolve
s
thanks Yousaf, I updated my Jenkinsfile stage "Unit Tests": { sh('make install') env.PATH = "$PATH:$HOME/pact/bin" echo "latest PATH value is : ${env.PATH}" sh('make test-unit') },
Copy code
latest PATH value is : /usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/go/bin:/root/go/bin:/usr/bin:/usr/local/bin:/usr/local/go/bin:/root/pact/bin
still same issue 160354 2023/06/06 150354 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0 160354 2023/06/06 150354 [ERROR] CLI tools are out of date, please upgrade before continuing
y
I'm not sure that is the path you downloaded the tools too, your logs previously showed it was downloading to
pact/bin
relative to your project folder, not the root
s
it says
Copy code
17:13:33  + echo 'pact-ruby-standalone v2.0.1 installed to /workspace/ntract-testing-poc-consumer_PR-6/pact'
17:13:33  pact-ruby-standalone v2.0.1 installed to /workspace/ntract-testing-poc-consumer_PR-6/pact
171333 + echo 'pact-ruby-standalone v2.0.1 installed to /workspace/ntract-testing-poc-consumer_PR-6/pact' 171333 pact-ruby-standalone v2.0.1 installed to /workspace/ntract-testing-poc-consumer_PR-6/pact 171333 + echo ------------------- 171333 ------------------- 171333 + echo 'available commands:' 171333 available commands: 171333 + echo ------------------- 171333 ------------------- 171333 ++ pwd 171333 + ls -1 /workspace/ntract-testing-poc-consumer_PR-6/pact/bin 171333 pact 171333 pact-broker 171333 pact-message 171333 pact-mock-service 171333 pact-plugin-cli 171333 pact-provider-verifier 171333 pact-publish 171333 pact-stub-service 171333 pactflow 171333 [Pipeline] echo 171333 latest PATH value is : /usr/sbin/usr/bin/sbin/bin/sbin/usr/sbin/bin/usr/bin/usr/local/bin/usr/local/go/bin/root/go/bin/usr/bin/usr/local/bin/usr/local/go/bin/pact/bin 171333 [Pipeline] sh 171333 + make test-unit 171333 go test -v -coverprofile=coverage_unit.out $(go list ./... | grep -v /practiceExamples) 171400 === RUN TestHandler_ModelMandatoryCheck 171400 2023/06/06 161400 [INFO] checking pact-provider-verifier within range >= 1.36.1, < 2.0.0 171400 2023/06/06 161400 [ERROR] CLI tools are out of date, please upgrade before continuing
y
the path is /workspace/ntract-testing-poc-consumer_PR-6 in the folder pact/bin it is shown in the output of the downloader
☝️ 1
🙏 1
s
thanks Yousaf, very helpful
I have defined path setup like this
#Install Pact CLI
install-pact-cli:
@if [ ! -d pact/bin ]; then\
echo "--- Installing Pact CLI dependencies"; \
curl -fsSL <https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh> | bash -x; \
fi
update-path:
@echo "adding pact-cli to the PATH..."
PATH:=$(PATH):$(PWD)/pact/bin
chefkiss 1
and updated Jenkinsfile with stage('Unit Tests'){ sh('make install-pact-cli') sh('make update-path') sh('make test-unit') }
tests passing now
thank you very much
y
awesome