Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I modify a Jenkins plugin to stop it from putting a link on build pages?

I'm trying to modify the existing EnvInject plugin so that the Environment Variables link it puts on a build's page is hidden. If I'm understanding the Jenkins API correctly, I should be able to do this by finding where the Action interface is implemented and having getIconFileName() return null.

I found that method implemented in EnvInjectAction.java and modified it to return null, but this had no effect--the link is still visible on build pages. I even tried modifying getDisplayName() and getUrlName() to also return null, but this also had no effect. Here is the modified method:

public String getIconFileName() {
        return null;
}

I've taken care to follow the instructions for deploying a custom build of a core plugin from the Jenkins plugin tutorial, and I've also tried rebooting the machine that Jenkins is running on, all to no avail.

I'm clearly missing something vital, but I can't figure out what it could be. What else do I need to do to make the plugin not display the Environment Variables link?

like image 536
khagler Avatar asked Oct 14 '14 19:10

khagler


People also ask

What is pinned plugin?

The notion of pinned plugins applies to plugins that are bundled with Jenkins, such as the Matrix Authorization plugin. If you do nothing special, whenever Jenkins is upgraded, its bundled plugins overwrite whatever versions of the plugins are currently installed in $JENKINS_HOME.


1 Answers

Why do you want to do that? To hide sensitive information?

Are you aware of that even if you remove the link the variables can be displayed via:
http://jenkins/job/YourJob/1/injectedEnvVars?

Or according to the EnvInjectPlugin-VariablesTraceability:

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

However, if it's just to remove the link and modifying the plugin is not a must 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 since it might get overwritten with a:

$ sudo service jenkins --full-restart

UPDATE

You can use a custom CSS with the following:

Manage Jenkins → Configure System → ThemeURL of theme CSS: ...

like image 145
Gerold Broser Avatar answered Oct 12 '22 23:10

Gerold Broser