问题
I am trying to deploy a mule application on cloud hub using Azure Devops. While trying to deploy the application I am running a job which have a task Maven that is suppose to run a maven command:
mvn package deploy -DmuleDeploy -Dcloud.env=Sandbox -Danypoint.businessGroup=TestBusiness -Dcloudhub.workerType=Small -DcloudhubAppName=testdeployment -Dmule.version=4.2.2 -Dcloud.user=UserUser -Dcloud.password=***
That should deploy the build using the pom.xml file on cloud hub But I am getting this error:
Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format
<plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>
Below is my pom.xml file ` 4.0.0
<groupId>com.mycompany</groupId>
<artifactId>testdeployment</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>
<name>testdeployment</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<app.runtime>4.2.2</app.runtime>
<mule.maven.plugin.version>3.3.5</mule.maven.plugin.version>
</properties>
<build>
<defaultGoal>mvn deploy</defaultGoal>
<plugins>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<cloudHubDeployment>
<uri>https://anypoint.mulesoft.com</uri>
<muleVersion>${app.runtime}</muleVersion>
<username>${anypoint.username}</username>
<password>${anypoint.password}</password>
<businessGroup>${businessGroup}</businessGroup>
<workers>${workers}</workers>
<workerType>${workerType}</workerType>
<region>us-west-1</region>
<environment>${environment}</environment>
<applicationName>${applicationName}</applicationName>
<properties>
<mule.env>${mule.env}</mule.env>
<encrypt.key>${encrypt.key}</encrypt.key>
<anypoint.platform.client_id>${anypoint.platform.client_id}
</anypoint.platform.client_id>
<anypoint.platform.client_secret>${anypoint.platform.client_secret}</anypoint.platform.client_secret>
<api.id>${ilg.api.version}</api.id>
<anypoint.platform.config.analytics.agent.enabled>true</anypoint.platform.config.analytics.agent.enabled>
</properties>
</cloudHubDeployment>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.5.11</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.1.5</version>
<classifier>mule-plugin</classifier>
</dependency>
</dependencies>
<repositories>
<repository>
<id>anypoint-exchange-v2</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v2/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
`
回答1:
The error is because you put the mvn
command inside the <defaultGoal>
element. mvn
is the command line to execute Maven. It has no meaning inside a pom. Remove it and leave a real Maven goal, like deploy
.
Example:
<defaultGoal>deploy</defaultGoal>
Note that using deploy
will also try to execute Maven deployments in addition to CloudHub deployments. mule:deploy
might be more useful just to deploy to CloudHub.
来源:https://stackoverflow.com/questions/62642637/unknown-lifecycle-phase-mvn-you-must-specify-a-valid-lifecycle-phase-or-a-go