简体   繁体   English

Maven 使用 azure CICD - 如何保护我的用户凭据

[英]Maven using azure CICD - How to secure my user credentials

I am having my test case ready in local environment and ready to shift in azure CICD pipeline.我正在本地环境中准备好我的测试用例,并准备好转移到 azure CICD 管道中。

TO run the test case I need few settings including User credentials.要运行测试用例,我需要一些设置,包括用户凭据。 Now when I move my code from local to clod I can't pass user credential because of security concern.现在,当我将代码从本地移动到 clod 时,出于安全考虑,我无法传递用户凭据。

I read some article on Azure Key Vault to save secrets and then we can read it in pipeline.我阅读了一些关于 Azure Key Vault 的文章来保存机密,然后我们可以在管道中阅读它。

But any one know how can I pass/read Azure key vault secrets in Maven task of Azure Pipeline so that I have don't have to save credentials in code itself.但是任何人都知道如何在 Azure Pipeline 的 Maven 任务中传递/读取 Azure Key Vault 机密,这样我就不必在代码本身中保存凭据。

Other solutions also welcome.也欢迎其他解决方案。

One of the option would be use variable group .选项之一是使用变量组 You may link variable group with Azure Key Vault:您可以将变量组与 Azure Key Vault 链接:

在此处输入图片说明

And then when you use this variable group in pipeline you will get secrets available as variables.然后,当您在管道中使用此变量组时,您将获得可用作变量的秘密。

So if you have secret MyPassword in Azure Key Vault and you will follow all above steps then in pipeline you may reffer to it as $(MyPassword) .因此,如果您在 Azure Key Vault 中有秘密的MyPassword并且您将遵循上述所有步骤,那么在管道中您可以将其称为$(MyPassword)

Another options is to use Azure Key Vault task另一种选择是使用Azure Key Vault 任务

In the simplest manner you can use secret variable:以最简单的方式,您可以使用秘密变量: 在此处输入图片说明

Or secret variable in variable group:或变量组中的秘密变量:

在此处输入图片说明

In Maven task you can use variable like this mavenPomFile: $(YourVariables) :在 Maven 任务中,您可以使用像这样的变量mavenPomFile: $(YourVariables)

- task: Maven@3
  inputs:
    mavenPomFile: $(YourVariables)
    publishJUnitResults: true
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    javaHomeOption: 'JDKVersion'
    mavenVersionOption: 'Default'
    mavenAuthenticateFeed: false
    effectivePomSkip: false
    sonarQubeRunAnalysis: false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM