Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-56482

custom name variable seems to not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Minor Minor
    • _unsorted
    • Azure Credentials 1.6.0
      Jenkins ver. 2.150.3
      Centos 7.4

      Hello,

      Before, I used Environment variables in Jenkins configuration to set Azure credentials and my terraform init worked.

      I installed the Azure credentials in order to use several tenant credentials.

      but my terraform init complain this:

      Error configuring the backend "azurerm": resource_group_name and credentials must be provided when access_key is absent

      when I set back Environment variables in Jenkins, everything works.

      this is my pipeline script:

       

      ---------------

       
      def checkout() {
      stage('Clone repository') {
      git branch: 'dev',
      credentialsId: 'gitalb-token-ci',
      url: 'https://url.git'
      sh "ls -lat"
      }
      }
       
      def terraformFmt() {
      stage('Terraform fmt') {
      sh 'terraform fmt'
      }
      }

      def terraformInit() {
      stage('Terraform Init') {
      sh "az login --service-principal -u $CLIENT_ID -p $CLIENT_SECRET -t $TENANT_ID"
      sh "az account set -s $SUBS_ID"
      sh "terraform init"
      }
      }

      def terraformPlan() {
      stage('Terraform Plan') {
      sh "terraform plan -input=false"
      }
      }

      def terraformApply() {
      stage('Terraform Apply') {
      input "Are you ready for APPLY ?"
      sh "terraform apply -input=false -auto-approve"
      }
      }
       
      node {
      withCredentials([azureServicePrincipal(credentialsId: 'credentials_id_ci,
      subscriptionIdVariable: 'SUBS_ID',
      clientIdVariable: 'CLIENT_ID',
      clientSecretVariable: 'CLIENT_SECRET',
      tenantIdVariable: 'TENANT_ID')]) {
       
      checkout()
      terraformFmt()
      terraformInit()
      terraformPlan()
      terraformApply()
      }
      ---------------
       
      thanks for your help.

            jieshe Jie Shen
            krugg3r Omega BK
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: