Below code works and helps fetch username and password from Jenkins credentials in a piepeline.
withCredentials([usernamePassword(credentialsId: 'mysql_creds', passwordVariable: 'sqlpassword', usernameVariable: 'sqlusername')]) { creds = "\nUsername: ${sqlusername}\nPassword: ${sqlpassword}\n" sqlu = "${sqlusername}" sqlp = "${sqlpassword}" }
I need to get the same username and password directly in a Jenkins Job without using pipelines.
I copy the same above code a build step execute shell (unix) but when I run the job its gives me the below error:
syntax error near unexpected token `[usernamePassword’
Build step ‘Execute shell’ marked build as failure
Can you please help me with the code that works with a Plain Jenkins Job execute shell script where these credentials are needed to be passed.