How to change the Jenkins plugin so that it does not put a link to the assembly pages?

I am trying to modify an existing EnvInject plugin so that the Environment Variables link placed on the assembly page is hidden. If I understand the Jenkins API correctly, I have to do this by finding where the Action interface is implemented and getIconFileName() return null .

I found this method implemented in EnvInjectAction.java and changed it to return null , but that didnโ€™t affect - the link is still visible on the assembly pages. I even tried modifying getDisplayName() and getUrlName() to return null , but that also had no effect. Here is a modified method:

 public String getIconFileName() { return null; } 

I made sure to follow the instructions for deploying the custom assembly of the main plugin from the Jenkins plugin tutorial, and I also tried to reboot the machine that Jenkins is working on, all to no avail.

I am clearly missing something vital, but I cannot understand what it can be. What else do I need to do to prevent the plugin from displaying the "Environment Variables" link?

+6
source share
2 answers

Why would you want to do that? Hide confidential information?

Did you know that even if you delete the link, variables can be displayed through:
http://jenkins/job/YourJob/1/injectedEnvVars ?

Or according to EnvInjectPlugin-VariablesTraceability :

"You can also get build environment variables as follows
HTTP GET URL: <jenkins_url>/job/<job_name>/<build_number>/injectedEnvVars/export "

However, if you simply remove the link and change the plugin, you do not need to add the following to Jenkins' run/jenkins/war/css/style.css :

 a[href*='/injectedEnvVars'] { display: none; } 

Make a backup copy of the adapted style.css , as it can be overwritten with:

 $ sudo service jenkins --full-restart 

UPDATE

You can use custom CSS with the following:

Jenkins Management -> Configure System -> Theme -> CSS Theme URL: ...

+1
source

As an answer to overcome the limitations of comments.

I looked into the source of the plugin, and I can say that I selected EnvInjectAction.java's getDisplayName() to apply the changes. Because it contains return "Environment Variables"; and is the only file in the entire project that contains this particular line.

I noticed that EnvIinjectAction deprecated, but it doesnโ€™t harm anything.

You tried to return an empty or arbitrary string for testing, not null . Perhaps Jenkins himself does not like the null returned by this method. (But the next question: why is it still displaying the plugin source line.)

I even downloaded the jenkins-1.585 source sources and looked for getDisplayName() calls to check what was done with the return value, but 332 of them are from src/main/java. I'm still trying to find the right one.

Did you try the modified plugin on local Jenkins on your computer? Maybe something went wrong when you install the plugin on servers that are not supported by yourself.

Have you considered contact with an accompanying Gregory Byussino?

0
source

Source: https://habr.com/ru/post/976741/


All Articles