Unable to read credentials in Jenkins Job

17 views
Skip to first unread message

Mohtashim S

unread,
Oct 7, 2019, 5:28:56 AM10/7/19
to Ansible Project
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.   

Dick Visser

unread,
Oct 7, 2019, 12:07:44 PM10/7/19
to ansible...@googlegroups.com
I don't see anything related to Ansible in your question?
If there is - please share that and we can have a look.



Dick
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e0993d2e-61b6-4c1d-b137-b20b37922c3e%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

Mohtashim S

unread,
Oct 8, 2019, 2:47:32 AM10/8/19
to Ansible Project
Sorry, this question was regarding Jenkins. 

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


On Monday, October 7, 2019 at 9:37:44 PM UTC+5:30, Dick Visser wrote:
I don't see anything related to Ansible in your question?
If there is - please share that and we can have a look.



Dick

On Mon, 7 Oct 2019 at 11:29, Mohtashim S <mohta...@gmail.com> wrote:
>
> 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.
>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages