How to pass environment variable or string parameter in a Windows VM using jenkins as code using declarative syntax

98 views Asked by At
pipeline {
  agent {
    node {
      label 'xxx'
    }
  }
  environment {
    TESTPASSWORD_PSW = "${TESTPASSWORD}"
  }
  stages {
    stage("My Environemnt Pipeline")
    {
      steps {
        withCredentials([usernamePassword(credentialsId: 'MYCREDENTIAL',
          passwordVariable: 'TESTPASS', usernameVariable: 'TESTUSER')]) {
          echo "Have a look at ${TESTPASS}"
          echo "Have a look at ${TESTUSER}"
        }
      }
    }
  }
}

I tried using properties where I have defined the string and put the default value as the username above but on my Windows server VM in XXX, there is no variable such as that even I tried the option of defining a variable in the environment with the value of this credential but the SET command in command prompt didn't list out any environment variable How can I pass one password credentials to be used in Windows VM and use it in my code. Thanks for the help

0

There are 0 answers