0

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?

  1. I created a Jenkins secret with Microsoft Service Principal type.
  2. 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()
      }
    }

}

1 Answer 1

0

The solution is to update the plugin version to the version 2.263.4.2. In fact I was using the plugin version 4.0.6 and this secret initialization feature thanks to credentials plugin has been introduced in 216.ve0b_4a_485ffc2 version. You can find the question I asked on the Github plugin: https://github.com/jenkinsci/azure-credentials-plugin/issues/155#issuecomment-1339628355

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.