从Jenkins上下文访问本地运行的资源(如mongo db)

时间:2018-06-29 19:03:10

标签: jenkins jenkins-pipeline

我在可作为mongodb:// myusername:mypwd @ localhost:27017 / mydb访问的计算机上运行Mongo DB。 我已经编写了单元测试,该单元测试将在使用MongoDB的springboot应用程序上调用API。当我在mvn上下文中运行springboot应用程序时,一切正常。 当我在Jenkins中构建同一项目时,代码将编译,单元测试失败,并显示一条消息,指出MongoDB无法访问。实际的错误消息是:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-06-29 11:51:17.392 ERROR 16893 --- [           main] o.s.boot.SpringApplication               : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]

在Jenkins管道脚本中,我为MongoDB的URL声明了一个环境变量,并且具有正确的URL。

0 个答案:

没有答案