【问题标题】:Using exec-maven-plugin to run external program with secured token from azure pipeline使用 exec-maven-plugin 使用来自 azure 管道的安全令牌运行外部程序
【发布时间】:2022-01-14 14:00:29
【问题描述】:

这里有很多关于 exec-maven-plugin 的问题,但这是不同的。我正在尝试使用 exec-maven-plugin 在 maven 中运行具有 exec 目标的外部程序。要传递的参数之一是在 azure 管道上定义的安全令牌。

问题是,如果我对令牌进行硬编码,这意味着实际令牌值没有保护它并且我运行 mvn exec:exec 命令,它可以工作。但是当我从 azure 管道传递安全令牌时,它无法与外部程序通信。

有没有办法在将这个安全令牌作为参数传递给 exec-maven-plugin 之前对其进行解密,或者有没有其他方法可以让它工作?

pom的相关部分是:

<groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
              <version>3.0.0</version>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals>
                          <goal>exec</goal>
                      </goals>
                  </execution>
              </executions>
              <configuration>
                  <executable>java</executable>
                  <arguments>
                      <argument>-Djavax.net.ssl.trustStore=$(env.MAVEN_TRUST_STORE)</argument>
                      <argument>-jar</argument>
                      <argument>                            ${settings.localRepository}/com/github/externalprogram/ddd/$(ddd.version)/ddd-$(ddd.version).jar
                      </argument>
                      <argument>--externalprogram.url=https://xxxx.yyyy.com/</argument>
                      <argument>--externalprogram.proxy.host=${someproxy}</argument>
                      <argument>--externalprogram.proxy.port=0000</argument>
                      <argument>--externalprogram.api.token=$**(secure-token)**</argument>
                      <argument>--detect.maven.path=$(env.M2_HOME)/bin/$(mvn)</argument>
                      <argument>--detect.maven.include.plugins=true</argument>
                      <argument>--detect.maven.build.command=-s $(env.MAVEN_SETTINGS_XML) -Djavax.net.ssl.trustStore=$(env.MAVEN_TRUST_STORE)
                      </argument>
                      <argument>--detect.included.detector.types=maven,pip,npm</argument>
                      <argument>
                          --detect.externalprogram.signature.scanner.exclusion.name.patterns=*target*,*/target,*\target
                      </argument>
                      <argument>--detect.bdio2.enabled=false</argument>
                      <argument>--detect.project.version.phase=$(versionPhase)</argument>
                      <argument>--detect.code.location.name=${project.version}</argument>
                  </arguments>
              </configuration>
          </plugin>

因此,如果我用实际值替换安全令牌,它就可以工作。但是当我使用安全值时,它会失败并出现错误:无法与外部程序通信。未授权...

【问题讨论】:

    标签: java maven azure-devops azure-pipelines-yaml


    【解决方案1】:

    您如何定义安全令牌?

    注意:秘密变量默认不传递给环境变量

    参考:https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#secret-variables

    【讨论】:

      猜你喜欢
      • 2012-11-08
      • 2016-01-31
      • 1970-01-01
      • 2017-01-22
      • 2013-02-25
      • 2019-10-16
      • 2018-08-12
      • 2021-04-08
      • 1970-01-01
      相关资源
      最近更新 更多