# Unable to read credentials in Jenkins Job

**URL:** <https://forum.ansible.com/t/unable-to-read-credentials-in-jenkins-job/31428>\
**Category:** Ansible Project\
**Created:** [October 7, 2019, 9:28am UTC](https://forum.ansible.com/t/unable-to-read-credentials-in-jenkins-job/31428 "2019-10-07T09:28:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Easy\_King](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@Easy\_King](https://forum.ansible.com/u/Easy_King)\
**Post date:** [October 7, 2019, 9:28am UTC](https://forum.ansible.com/t/unable-to-read-credentials-in-jenkins-job/31428/1 "2019-10-07T09:28:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [October 7, 2019, 4:07pm UTC](https://forum.ansible.com/t/unable-to-read-credentials-in-jenkins-job/31428/2 "2019-10-07T16:07:15Z")

</div>

I don't see anything related to Ansible in your question?  
If there is - please share that and we can have a look.

Dick

---

<div class="post-metadata">

**Author:** ![Easy\_King](https://avatars.discourse-cdn.com/v4/letter/e/c2a13f/32.png) [@Easy\_King](https://forum.ansible.com/u/Easy_King)\
**Post date:** [October 8, 2019, 6:47am UTC](https://forum.ansible.com/t/unable-to-read-credentials-in-jenkins-job/31428/3 "2019-10-08T06:47:31Z")

</div>

Sorry, this question was regarding Jenkins.

We can ignore and delete this post as I have re-posted this in the Jenkins group.
