Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in DevOps and Agile by (29.3k points)

I have already added 2 secret files to Jenkin's credentials with names PRIVATE-KEY and PUBLIC-KEY. How can I copy those 2 files to /src/resources directory inside a job?

I have the following snippet

withCredentials([file(credentialsId: 'PRIVATE_KEY', variable: 'my-private-key'),

                 file(credentialsId: 'PUBLIC_KEY', variable: 'my-public-key')]) {

   //how to copy, where are those files to copy from?

}

1 Answer

0 votes
by (19.4k points)

To copy the secret my-private-key variable is a path to the secret, so I had to copy that secret to the destination I needed.

withCredentials([file(credentialsId: 'PRIVATE_KEY', variable: 'my-private-key'),

                 file(credentialsId: 'PUBLIC_KEY', variable: 'my-public-key')]) {

   sh "cp \$my-public-key /src/main/resources/my-public-key.der"

   sh "cp \$my-private-key /src/main/resources/my-private-key.der"

}

Browse Categories

...