0

我在 Windows 上使用 XLDeploy“xl-deploy-8.2.1-server-trial-edition”以 DevOps 方式测试基于 Spring 的应用程序部署管道。我有执行某些 Maven 目标的 Jenkins:

  1. 建立战争(目标包)
  2. dar(目标 xldeploy:generate-deployment-package 映射到阶段包)
  3. 将战争部署到 Nexus(目标部署)
  4. 将 dar 导入到 XLDeploy 内部存储库(目标 xldeploy:import 映射到部署阶段)
  5. 将战争部署到 UAT 环境(目标 xldeploy:deploy)

我正在使用xldeploy-maven-plugin版本 6.0.x。

执行 xldeploy:deploy 目标时出现问题:

#mvn clean package deploy xldeploy:deploy

XLDeploy 服务器抱怨“已经导入的版本”,更准确地说:

2018-12-05 16:00:03.540 [qtp251546027-45] {username=admin} INFO  c.x.x.p.SourceArtifactEnricher - Going to scan artifact Applications/SGS/SBO/RETAIL/PI/ALPHA/market-securities-account/1.0.0-20181205-155919/market-securities-account
2018-12-05 16:00:09.722 [qtp251546027-46] {username=admin} INFO  c.x.d.r.m.DeployitExceptionMapper - Already imported version 1.0.0-20181205-155919 of application SGS/SBO/RETAIL/PI/ALPHA/market-securities-account
2018-12-05 16:00:09.724 [qtp251546027-46] {username=admin} INFO  c.x.d.r.m.DeployitExceptionMapper - Intercepting DeployitException
com.xebialabs.deployit.service.importer.ImporterException: Already imported version 1.0.0-20181205-155919 of application SGS/SBO/RETAIL/PI/ALPHA/market-securities-account
        at com.xebialabs.deployit.service.importer.ImporterServiceImpl.checkImported(ImporterServiceImpl.java:222)
        at com.xebialabs.deployit.service.importer.ImporterServiceImpl.doImport(ImporterServiceImpl.java:144)
        at com.xebialabs.deployit.service.importer.ImporterServiceImpl.importPackage(ImporterServiceImpl.java:129)
        at com.xebialabs.deployit.core.rest.api.PackageResource.doImport(PackageResource.java:107)
        at com.xebialabs.deployit.core.rest.api.PackageResource.upload(PackageResource.java:103)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)

实际上,Maven 通过部署阶段(映射到 xldeploy:import 目标)已经将 dar 导入到 XLDeploy 服务器,并且 xldeploy:deploy 阶段尝试再次导入相同的 dar。为什么?根据 xldeploy-maven-plugin 文档,部署目标只进行部署而不是 dar 导入。

如果我之前删除了导入目标调用,映射到部署阶段,那么只需调用:

#mvn clean package xldeploy:deploy

我已将 dar 导入到 XLDeploy 服务器中,并且在服务器控制台中可以看到执行的部署计划:

# [Phased plan]
# [Plan phase]
 * Register changes for market-securities-account
   ----------------------------------------------
 1. (100) - Register deployeds  (step: RepositoryUpdateStep, rule: null)

其中包括仅将应用程序注册为已部署,但在我的 2 个 Tomcat 上没有真正部署任何内容。

但是通过 Web UI 部署时,我在控制台中有以下计划:

# [Phased plan]
# [Plan phase] Deploy
#########################################################################
# [Serial] Deploy market-securities-account 1.0.0-20181205-165054 on DEV
#########################################################################
    | * Deploy on container VirtualHost (Group default)
    |   -----------------------------------------------
    | 1. ( 10) - Stop Tomcat2  (step: ScriptExecutionStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    | 2. ( 11) - Waiting 10 seconds for Tomcat2 to stop  (step: WaitStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    | 3. ( 60) - Create war settings in market-securities-account.xml on VirtualHost  (step: TemplateArtifactCopyStep, rule: tomcat.WarModule.executeCreate_CREATE)
    | 4. ( 70) - Create market-securities-account on VirtualHost  (step: ArtifactCopyStep, rule: tomcat.WarModule.executeCreate_CREATE)
    |            *checkpoint*  CREATE Infrastructure/DEV/VM_ALPHA2_DEV/Tomcat2/VirtualHost/market-securities-account
    | 5. ( 90) - Start Tomcat2  (step: ScriptExecutionStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    | 6. ( 91) - Waiting 10 seconds for Tomcat2 to start  (step: WaitStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    |-------------------------------------------->
    | * Deploy on container VirtualHost (Group 1)
    |   -----------------------------------------
    | 1. ( 10) - Stop Tomcat1  (step: ScriptExecutionStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    | 2. ( 11) - Waiting 10 seconds for Tomcat1 to stop  (step: WaitStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    | 3. ( 60) - Create war settings in market-securities-account.xml on VirtualHost  (step: TemplateArtifactCopyStep, rule: tomcat.WarModule.executeCreate_CREATE)
    | 4. ( 70) - Create market-securities-account on VirtualHost  (step: ArtifactCopyStep, rule: tomcat.WarModule.executeCreate_CREATE)
    |            *checkpoint*  CREATE Infrastructure/DEV/VM_ALPHA1_DEV/Tomcat1/VirtualHost/market-securities-account
    | 5. ( 90) - Start Tomcat1  (step: ScriptExecutionStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
    | 6. ( 91) - Waiting 10 seconds for Tomcat1 to start  (step: WaitStep, rule: com.xebialabs.deployit.plugin.generic.container.LifeCycleContributor.restartContainers)
# [Plan phase]
 * Register changes for market-securities-account
   ----------------------------------------------
 1. (100) - Register deployeds  (step: RepositoryUpdateStep, rule: null)

为什么会有这种差异?是不是因为我的可部署应用程序没有自动定位到环境容器,如下面的屏幕截图所述?

通过 UI 进行 XLDeploy 部署计划

当尝试使用 PetClinic 战争示例时,容器会自动成为目标,为什么?

此致。

4

3 回答 3

0

关于部署计划,问题是 VirtualHost CI on Infrastructure 部分中缺少标签“webapp”。

于 2018-12-12T08:50:22.277 回答
0

这是对的。xldeploy:deploy目标还执行导入。这使您应该在 Jenkins 中添加一些逻辑,例如(伪代码): if no deploy: execute xldeploy:import if deploy: execute xldeploy:deploy

于 2018-12-14T19:13:40.193 回答
0

我遇到了一个already imported错误,但这是因为我正在创建一个新包但发布了一个旧包,它确实已经被导入了。

于 2021-09-08T05:51:36.113 回答