简体   繁体   中英

Jenkins (freestyle project) secret text using Parameter expression

I have a python project that I'm using pytest with integration to Report Portal.
I execute the tests from Jenkins (freestyle project).

In order to to get the user name for each session in Report Portal, I need to know the Report Portal access_token of the user.
After finding those, I added to Jenkins for each user a secret text with the ID as the user Jenkins BUILD_USER_ID .

Next, In the Jenkins configure page, I clicked on Use secret text(s) or file(s) under Build Environment
Then clicked on Add and Secret text .
I called the Variable RP_UUID .
And set Credentials to Parameter expression .

Jenkins gave me a hint:

A valid parameter expression consists of the parameter name enclosed within ${ and }

I tried to set this filed to be ${ BUILD_USER_ID } , but I got the following error:

Rebuilds build #17
Running as SYSTEM
Building remotely on Automation in workspace /var/lib/jenkins/workspace/test
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Deferred wipeout is used...
[WS-CLEANUP] Done
ERROR: Could not find credentials entry with ID '${ BUILD_USER_ID }'
Finished: FAILURE

I tried all sorts of things, but it seems that Jenkins in this stage doesn't recognize any variable name.

Any idea how to resolve this, or any different approach?

ps
The field Set Jenkins user build variables is ticked.

See JENKINS-36470 the only parameter type that can be expanded in the Parameter expression section is a Credentials Parameter. All other parameters are not supported. So if you want to use this mechanism you must define the input parameter as a Credentials type:

在此处输入图像描述

You'd probably need to set "Run as SYSTEM" in Access Control for Builds at

https://jenkins-url/configureSecurity

在此处输入图像描述

When I used "Run as SYSTEM" just for "Project default Build Authorization" it didn't work. Once I set it also under " Per-project configurable Build Authorization " - Then the triggered job could evaluate the parameter expression for the credentials bindings.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM