I try to factorize the use of my Azure credentials inside my Jenkins pipeline. Instead of using withCredentials inside each stage of my pipeline I would like to initialize it into one environment variable. I use Azure credentials plugin (version 4.0.6) and my Jenkins is in version 2.263.4.2.
I read the plugin documentation https://plugins.jenkins.io/azure-credentials/#plugin-content-declarative-pipeline and despite of that I met an issue:
ERROR: No suitable binding handler could be found for type com.microsoft.azure.util.AzureCredentials. Supported types are StandardUsernamePasswordCredentials,FileCredentials,DockerServerCredentials,StringCredentials,AmazonWebServicesCredentials,SSHUserPrivateKey.
It seems to be an error with secret type but in the plugin documentation, it does not seem to be a problem.
Did anyone ever try to use environment block in addition with credentials and Azure Service Principal secret please?
- I created a Jenkins secret with Microsoft Service Principal type.
- I implemented my Jenkins declarative pipeline code:
pipeline {
agent {
node {
label 'your_node_label'
}
}
options {
ansiColor('xterm')
}
environment {
ARM = credentials('my_credentials_id')
}
stages {
stage('Terraform Init'){
steps {
sh """
echo "Test"
"""
}
}
}
post {
always {
cleanWs()
}
}
}