Compartilhar via


AzurePipelinesCredentialBuilder Class

public class AzurePipelinesCredentialBuilder
extends AadCredentialBuilderBase<AzurePipelinesCredentialBuilder>

The AzurePipelinesCredentialBuilder provides a fluent builder for AzurePipelinesCredential.

// serviceConnectionId is retrieved from the portal.
 // systemAccessToken is retrieved from the pipeline environment as shown.
 // You may choose another name for this variable.

 String systemAccessToken = System.getenv("SYSTEM_ACCESSTOKEN");
 AzurePipelinesCredential credential = new AzurePipelinesCredentialBuilder().clientId(clientId)
     .tenantId(tenantId)
     .serviceConnectionId(serviceConnectionId)
     .systemAccessToken(systemAccessToken)
     .build();

Constructor Summary

Constructor Description
AzurePipelinesCredentialBuilder()

Creates an instance of the AzurePipelinesCredentialBuilder.

Method Summary

Modifier and Type Method and Description
AzurePipelinesCredential build()

Builds an instance of the AzurePipelinesCredential with the current configurations.

AzurePipelinesCredentialBuilder serviceConnectionId(String serviceConnectionId)

Sets the service connection id for the Azure Pipelines service connection.

AzurePipelinesCredentialBuilder systemAccessToken(String systemAccessToken)

Sets the System Access Token for the Azure Pipelines service connection.

AzurePipelinesCredentialBuilder tokenCachePersistenceOptions(TokenCachePersistenceOptions tokenCachePersistenceOptions)

Configures the persistent shared token cache options and enables the persistent token cache which is disabled by default.

Methods inherited from AadCredentialBuilderBase

Methods inherited from CredentialBuilderBase

Methods inherited from java.lang.Object

Constructor Details

AzurePipelinesCredentialBuilder

public AzurePipelinesCredentialBuilder()

Creates an instance of the AzurePipelinesCredentialBuilder.

Method Details

build

public AzurePipelinesCredential build()

Builds an instance of the AzurePipelinesCredential with the current configurations. Requires setting the following parameters:

Requires the SYSTEM_OIDCREQUESTURI environment variable to be set.

Returns:

an instance of the AzurePipelinesCredential.

serviceConnectionId

public AzurePipelinesCredentialBuilder serviceConnectionId(String serviceConnectionId)

Sets the service connection id for the Azure Pipelines service connection. The service connection ID is retrieved from the Service Connection in the portal.

Parameters:

serviceConnectionId - The service connection ID, as found in the query string's resourceId key.

Returns:

the updated instance of the builder.

systemAccessToken

public AzurePipelinesCredentialBuilder systemAccessToken(String systemAccessToken)

Sets the System Access Token for the Azure Pipelines service connection. The system access token is retrieved from the pipeline variables by assigning it to an environment variable and reading it. See AzurePipelinesCredential for more information.

Parameters:

systemAccessToken - the system access token for the Azure Pipelines service connection.

Returns:

The updated instance of the builder.

tokenCachePersistenceOptions

public AzurePipelinesCredentialBuilder tokenCachePersistenceOptions(TokenCachePersistenceOptions tokenCachePersistenceOptions)

Configures the persistent shared token cache options and enables the persistent token cache which is disabled by default. If configured, the credential will store tokens in a cache persisted to the machine, protected to the current user, which can be shared by other credentials and processes.

Parameters:

tokenCachePersistenceOptions - the token cache configuration options

Returns:

An updated instance of this builder with the token cache options configured.

Applies to