Credentials "secret text" -> bash -> expect ?

17 afișări
Accesați primul mesaj necitit

b o b i

necitită,
15 mai 2019, 09:47:2815.05.2019
– Jenkins Users
Im using expect to inject a password into an openssl command called from a make file (and spawned by expect).

However, Im not able to pass the secret. Any suggestions on why this is happening?

makeFileWith.mk contains an openssl command requiring a secret

stage ('Deploy') {
   withCredentials([string(credentialsId: 'secretText', variable: 'varSecretText')]) {

        sh """#!/usr/bin/expect

        puts "SECRET $varSecretText"

        exp_internal 1
        spawn make -f makeFileWith.mk
        
        expect "Enter Password:" {
           send \"${varSecretText}\n\"
        }
        """
   }
}

Output is
SECRET ****
...
expect: does "" (spawn_id exp3) match glob pattern "Enter Password:"? no

Is this Jenkins Bug or do I need something more / another approach ?


Ivan Fernandez Calvo

necitită,
15 mai 2019, 13:31:2715.05.2019
– Jenkins Users
If your secret is multiline, the secret text does not work as expected, you could store the one line base64 value of your secret and decode it before send it, it could work

b o b i

necitită,
16 mai 2019, 00:13:5816.05.2019
– Jenkins Users
It is a single line secret, but it wont work :|

Mark Waite

necitită,
16 mai 2019, 00:19:5716.05.2019
– Jenkins Users
I'm accustomed to seeing variable references in groovy strings as "${variablename}", while it seemed in your example you were referencing it as "$variablename".  Is that an intentional difference, or accidental?

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/85dc81a4-6206-4286-9578-42f1bec2fcfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Thanks!
Mark Waite

b o b i

necitită,
16 mai 2019, 01:19:0216.05.2019
– Jenkins Users
Do you mean ?
send \"${varSecretText}\n\"

-->  it has {}

or do you mean

puts "SECRET $varSecretText"

--> it worked
SECRET ****

On Thursday, May 16, 2019 at 6:19:57 AM UTC+2, Mark Waite wrote:
I'm accustomed to seeing variable references in groovy strings as "${variablename}", while it seemed in your example you were referencing it as "$variablename".  Is that an intentional difference, or accidental?

On Wed, May 15, 2019 at 9:14 PM b o b i <bobis...@gmail.com> wrote:
It is a single line secret, but it wont work :|

On Wednesday, May 15, 2019 at 7:31:27 PM UTC+2, Ivan Fernandez Calvo wrote:
If your secret is multiline, the secret text does not work as expected, you could store the one line base64 value of your secret and decode it before send it, it could work

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkins...@googlegroups.com.


--
Thanks!
Mark Waite

b o b i

necitită,
16 mai 2019, 02:31:0516.05.2019
– Jenkins Users
Please disregard the question, and sorry for bothering.

It truned out, it is not a jenkins problem, rather a problem with timing of the expect script

so putting sleep 2 before and after send solved the problem
Răspundeți tuturor
Răspundeți autorului
Redirecționați
0 mesaje noi