Package com.microsoft.azure.util
Class AzureCredentialsBinding
java.lang.Object
hudson.model.AbstractDescribableImpl<org.jenkinsci.plugins.credentialsbinding.MultiBinding<C>>
org.jenkinsci.plugins.credentialsbinding.MultiBinding<AzureCredentials>
com.microsoft.azure.util.AzureCredentialsBinding
- All Implemented Interfaces:
ExtensionPoint
,Describable<org.jenkinsci.plugins.credentialsbinding.MultiBinding<AzureCredentials>>
public class AzureCredentialsBinding
extends org.jenkinsci.plugins.credentialsbinding.MultiBinding<AzureCredentials>
Custom binding for AzureCredentials to support reading Azure service principal in both freestyle
and pipeline using Credentials Binding plugin.
There're two ways to construct this binding:
- With defaults, which will read specified service principal into four predefined environment variables:
AZURE_SUBSCRIPTION_ID
,AZURE_CLIENT_ID
,AZURE_CLIENT_SECRET
,AZURE_TENANT_ID
. Sample pipeline code:withCredentials([azureServicePrincipal('credentials_id')]) { sh 'az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET -t $AZURE_TENANT_ID' }
- With custom name, where you can control the names of the variables. Sample pipeline code:
withCredentials([azureServicePrincipal(credentialsId: 'credentials_id', subscriptionIdVariable: 'SUBS_ID', clientIdVariable: 'CLIENT_ID', clientSecretVariable: 'CLIENT_SECRET', tenantIdVariable: 'TENANT_ID')]) { sh 'az login --service-principal -u $CLIENT_ID -p $CLIENT_SECRET -t $TENANT_ID' }
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jenkinsci.plugins.credentialsbinding.MultiBinding
org.jenkinsci.plugins.credentialsbinding.MultiBinding.MultiEnvironment, org.jenkinsci.plugins.credentialsbinding.MultiBinding.NullUnbinder, org.jenkinsci.plugins.credentialsbinding.MultiBinding.Unbinder
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionorg.jenkinsci.plugins.credentialsbinding.MultiBinding.MultiEnvironment
bind
(Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) void
setClientIdVariable
(String clientIdVariable) void
setClientSecretVariable
(String clientSecretVariable) void
setSubscriptionIdVariable
(String subscriptionIdVariable) void
setTenantIdVariable
(String tenantIdVariable) protected Class<AzureCredentials>
type()
Methods inherited from class org.jenkinsci.plugins.credentialsbinding.MultiBinding
getCredentials, getCredentialsId, getDescriptor, variables
-
Field Details
-
DEFAULT_SUBSCRIPTION_ID_VARIABLE
- See Also:
-
DEFAULT_CLIENT_ID_VARIABLE
- See Also:
-
DEFAULT_CLIENT_SECRET_VARIABLE
- See Also:
-
DEFAULT_TENANT_ID_VARIABLE
- See Also:
-
-
Constructor Details
-
AzureCredentialsBinding
-
-
Method Details
-
setSubscriptionIdVariable
-
setClientIdVariable
-
setClientSecretVariable
-
setTenantIdVariable
-
getSubscriptionIdVariable
-
getClientIdVariable
-
getClientSecretVariable
-
getTenantIdVariable
-
type
- Specified by:
type
in classorg.jenkinsci.plugins.credentialsbinding.MultiBinding<AzureCredentials>
-
bind
public org.jenkinsci.plugins.credentialsbinding.MultiBinding.MultiEnvironment bind(@NonNull Run<?, ?> build, FilePath workspace, Launcher launcher, TaskListener listener) throws IOException, InterruptedException- Specified by:
bind
in classorg.jenkinsci.plugins.credentialsbinding.MultiBinding<AzureCredentials>
- Throws:
IOException
InterruptedException
-
variables
- Overrides:
variables
in classorg.jenkinsci.plugins.credentialsbinding.MultiBinding<AzureCredentials>
-