簡體   English   中英

Mulesoft Maven 部署到 RTF 401 未經授權

[英]Mulesoft Maven Deploy To RTF 401 Unauthorized

我正在嘗試使用 Maven 從 BitBucket 管道部署到 Mulesoft。 部署目標是為入站流量配置的 RTF 實例。 我正在使用以下 bitbucket-pipelines.yml:

image: maven:3.6.1

pipelines:
  branches:
    develop:
      - step:
          caches:
            - maven
          name: Deploy to test
          deployment: test
          script:
            - mvn clean package deploy -e -DskipMunitTests -DmuleDeploy -Dapp.name=$env.APPLICATION_NAME -Dgroup.id=$env.MULESOFT_GROUP_ID -Dapp.id=$env.MULESOFT_CONNECTED_APP_ID_DEV -Dapp.secret=$env.MULESOFT_CONNECTED_APP_DEV_SECRET -Drtf.name=$env.RUNTIME_FABRIC_NAME -Drtf.environment=$env.ANYPOINT_ENVIRONMENT -Dbusiness.group=$env.MULESOFT_BUSINESS_GROUP

這是我的 pom.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>GROUP GUID</groupId>
    <artifactId>APP NAME</artifactId>
    <version>1.0.0</version>
    <packaging>mule-application</packaging>

    <name>APP NAME</name>

    <description>APP DESCRIPTION</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <app.runtime>4.3.0</app.runtime>
        <mule.maven.plugin.version>3.4.1</mule.maven.plugin.version>
        <app.name>${env.APP_NAME}</app.name>
        <group.id>${env.GROUP_ID}</group.id>
        <app.id>${env.APP_ID}</app.id>
        <app.secret>${env.APP_SECRET}</app.secret>
        <rtf.name>${env.RTF_NAME}</rtf.name>
        <rtf.environment>${env.RTF_ENVIRONMENT}</rtf.environment>
        <business.group>${env.BUSINESS_GROUP}</business.group>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <groupId>org.mule.tools.maven</groupId>
                <artifactId>mule-maven-plugin</artifactId>
                <version>3.4.1</version>
                <extensions>true</extensions>
                <configuration>
                    <runtimeFabricDeployment>
                        <muleVersion>${app.runtime}</muleVersion>
                        <connectedAppClientId>${app.id}</connectedAppClientId>
                        <connectedAppClientSecret>${app.secret}</connectedAppClientSecret>
                        <connectedAppGrantType>client_credentials</connectedAppGrantType>
                        <applicationName>${app.name}</applicationName>
                        <target>${rtf.name}</target>
                        <environment>${rtf.environment}</environment>
                        <businessGroup>${business.group}</businessGroup>
                        <provider>MC</provider>
                    </runtimeFabricDeployment>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-http-connector</artifactId>
            <version>1.5.19</version>
            <classifier>mule-plugin</classifier>
        </dependency>
        <dependency>
            <groupId>org.mule.connectors</groupId>
            <artifactId>mule-sockets-connector</artifactId>
            <version>1.2.0</version>
            <classifier>mule-plugin</classifier>
        </dependency>
        <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-apikit-module</artifactId>
            <version>1.3.13</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>
        <pluginRepository>
            <id>mule-public</id>
            <url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
        </pluginRepository>
    </pluginRepositories>

</project>

我現在從管道中收到以下錯誤:

[INFO] --- mule-maven-plugin:3.4.1:deploy (default-deploy) @ APP NAME ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:00 min
[INFO] Finished at: 2020-09-11T15:24:36Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.mule.tools.maven:mule-maven-plugin:3.4.1:deploy (default-deploy) on project APP NAME: Execution default-deploy of goal org.mule.tools.maven:mule-maven-plugin:3.4.1:deploy failed: 401 Unauthorized: Unauthorized -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.mule.tools.maven:mule-maven-plugin:3.4.1:deploy (default-deploy) on project APP NAME: Execution default-deploy of goal org.mule.tools.maven:mule-maven-plugin:3.4.1:deploy failed: 401 Unauthorized: Unauthorized
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-deploy of goal org.mule.tools.maven:mule-maven-plugin:3.4.1:deploy failed: 401 Unauthorized: Unauthorized
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.mule.tools.client.core.exception.ClientException: 401 Unauthorized: Unauthorized
    at org.mule.tools.client.core.AbstractClient.checkResponseStatus (AbstractClient.java:175)
    at org.mule.tools.client.authentication.AuthenticationServiceClient.loginWithConnectedApp (AuthenticationServiceClient.java:152)
    at org.mule.tools.client.authentication.AuthenticationServiceClient.getBearerTokenForConnectedApp (AuthenticationServiceClient.java:91)
    at org.mule.tools.client.AbstractMuleClient.getBearerToken (AbstractMuleClient.java:347)
    at org.mule.tools.client.AbstractMuleClient.init (AbstractMuleClient.java:102)
    at org.mule.tools.client.core.AbstractClient.initialize (AbstractClient.java:123)
    at org.mule.tools.client.core.AbstractClient.get (AbstractClient.java:93)
    at org.mule.tools.client.fabric.RuntimeFabricClient.getDeployments (RuntimeFabricClient.java:55)
    at org.mule.tools.verification.fabric.RuntimeFabricDeploymentVerification$RuntimeFabricDeploymentVerificationStrategy.<init> (RuntimeFabricDeploymentVerification.java:51)
    at org.mule.tools.verification.fabric.RuntimeFabricDeploymentVerification$RuntimeFabricDeploymentVerificationStrategy.<init> (RuntimeFabricDeploymentVerification.java:45)
    at org.mule.tools.verification.fabric.RuntimeFabricDeploymentVerification.<init> (RuntimeFabricDeploymentVerification.java:37)
    at org.mule.tools.deployment.fabric.RuntimeFabricArtifactDeployer.<init> (RuntimeFabricArtifactDeployer.java:50)
    at org.mule.tools.deployment.fabric.RuntimeFabricArtifactDeployer.<init> (RuntimeFabricArtifactDeployer.java:41)
    at org.mule.tools.deployment.fabric.RuntimeFabricApplicationDeployer.<init> (RuntimeFabricApplicationDeployer.java:25)
    at org.mule.tools.deployment.AbstractDeployerFactory$RuntimeFabricDeployerFactory.createArtifactDeployer (AbstractDeployerFactory.java:170)
    at org.mule.tools.deployment.DefaultDeployer.<init> (DefaultDeployer.java:36)

我已確保從以下文檔向連接的應用程序提供權限: https : //help.mulesoft.com/s/article/The-Minimum-Permission-to-Deploy-an-Application-with-Anypoint-Console -or-Maven-in-RTF

我的組織是子組織,連接的應用程序是否需要主組織的權限? 我是否遺漏了一個我沒有看到的權限項目? 我對 BitBucket Pipelines 也不是很熟悉,我需要在 YAML 中添加任何內容嗎? 提前感謝您的幫助。

問題已解決。 有幾個問題。 首先,我的 Bitbucket 管道使用以下格式來注入存儲庫變量: $env.VAR_NAME 不需要使用env. 字首。 這些都更改為$VAR_NAME

接下來,我的解決方案屬於一個子組織,並且全名中有空格。 我將其更改為使用 businessGroupId,並使用子組織的 GUID。 這些一起使 maven 部署能夠正常工作。

注意:我還發現您不能在調試開關打開的情況下使用 BitBucket 管道。 下載所有依賴項時超時。

看起來您沒有在pom.xml mule maven 插件配置的<runtimeFabricDeployment>配置中提供您的 anypoint 平台用戶名或密碼。 因此,它無法進行身份驗證以進行部署。

配置參考在這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM