use of com.azure.resourcemanager.keyvault.models.Vault in project azure-credentials-plugin by jenkinsci.
the class KeyVaultIntegrationTestBase method setUp.
@Before
public void setUp() throws InterruptedException {
// Create Azure KeyVault
final AzureResourceManager azureClient = IntegrationTestBase.getAzureClient();
vaultName = "tst-vault-" + TestEnvironment.GenerateRandomString(5);
final Vault vault = azureClient.vaults().define(vaultName).withRegion(testEnv.region).withNewResourceGroup(testEnv.resourceGroup).defineAccessPolicy().forServicePrincipal(testEnv.clientId).allowSecretAllPermissions().attach().create();
vaultUri = vault.vaultUri();
waitForKeyVaultAvailable();
// Create Jenkins Azure Credentials
final AzureCredentials credentials = new AzureCredentials(CredentialsScope.SYSTEM, jenkinsAzureCredentialsId, "", testEnv.subscriptionId, testEnv.clientId, Secret.fromString(testEnv.clientSecret));
credentials.setTenant(testEnv.tenantId);
final CredentialsStore store = CredentialsProvider.lookupStores(j.jenkins).iterator().next();
try {
store.addCredentials(Domain.global(), credentials);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
Aggregations