JENKINS - Overriding specific target in config.xml - jenkins

I have 5 Jenkins servers (for projects) + 1 (for administration) with common a config.xml.
But for each server I want to have specific Dashboard view. These views are defined in the config.xml (tag : hudson.plugins.view.dashboard.Dashboard)
is there a way to have a specific configuration files and import it in the common config.xml (like a import resource="./config-specific.xml) ? (I try it= > don't work))
I can't have a specific config.xml by server, it must be common for each server.
Thanks

XIncludes could be a solution to that.
The only point is that you must enable the XInclude feature for the XML parser that's used by Jenkins (by default, it's disabled). If you're willing to modify core/src/main/java/hudson/XmlFile.java, then adding a JAXP.setXIncludeAware(true) should do the trick.
I didn't figure out yet if it's possible to do the same dynamically by setting a static system property like -D...=true. Also, XIncludes may be lost when Jenkins updates the config files itself.

Related

I want to enable 'Allowsignup' option by default in Jenkins

I have a groovy file that runs at the time of deployment to create predefined admin users for jenkins. I would like to add a logic here that would enable the allowsignup option. By default the option is disabled.
First I tried making changes in the config.xml file hoping that when I'd restart jenkins it would enable the option but that didn't work.
Now I'm suspecting that maybe I need to make changes via a groovy file using the hudson.security.HudsonPrivateSecurityRealm module, but I'm not exactly sure how to go about doing this.
I am also not sure whether this is possible or the option can only be enabled via UI.

TFS source control - prevent a specific line from merging

I have a Dev and a Main branch of a project. They are staged at different URLs and I hold a reference to this URL in my project in a static class:
public static class Constants
{
public const string Url = "http://staging.myurl.com";
}
Now the URL will be different in each branch, but I don't want the URLs overwriting each-other whenever I merge Dev->Main, or Main->Dev.
Is there a way of telling TFS that I don't want the line to be merged, or must this be done at file level instead?
Does anyone have any suggestions of how I can maintain independent URLs in each branch? I don't want to use a database or a config file if I can help it. Is there a simple mechanism to facilitate this in TFS?
I have thought about wrapping the line in a pre-compile #if statement and checking for a specific build configuration, but I'm curious to know if there is a better way?
As it stands, you're hard-coding infrastructure concerns directly into your application, which is bad. Your application code should be environment-agnostic.
This should be managed via a configuration file; it's one of the canonical use-cases for it. The configuration file can either be transformed into an environment-specific version at build time (via web.config transforms), or ideally, at the time of deployment, via your deployment scripts.
There's no way to ignore specific lines. You can ignore specific files (via .tfignore for TFVC, or via .gitignore for Git), but you can't just tell version control to not version control a specific line of a file.

How to properly configure Cygnus?

I was playing a bit with Cygnus, and I was wondering how to properly configure it. I’ve seen both agent_<id>.conf and cygnus_instance_<id>.conf files are needed. I understand the purpose of the first one, but not the second one. In addition, what about the grouping_rules.conf file? Is there any other configuration file?
File by file:
agent_<id>.conf file is the main configuration file for Cygnus. It inherits the syntax from Apache Flume, the base technology used by Cygnus, thus it is used to declare and specify the sources, channels and sinks of your Cygnus agent.
cygnus_instance_<id>.conf file is used to configure other Cygnus parameters that cannot be configured as part of the agent configuration, such as the logging file, the management interface port, etc. Cygnus service will run as many instances as cygnus_instance_<id>.conf files are configured. That's why an <id> must be provided, since this <id> will be used to find the proper agent_<id>.conf file.
grouping_rules.conf file is used when the Grouping Rules advanced feature is wanted to be used. Usually, this file may be empty (but it must exist) and Cygnus will run after all.
flume-env.sh file has been inherited from Apache Flume, and it is used in order to configure certain Flume paramters such as the classpath overwritting the default one, some Java options (-Xms, -Xmx, etc)...

Jenkins: prevent from reloading configuration

I am currently doing an analysis whether jenkins could fit for our needs.
Therefore I need to know something about (NOT) reloading configurations:
I know that there is an explicit way to reload a configuration (via WebGUI and CLI).
BUT:
Is there also a way to PREVENT Jenkins from reloading configs?
One requirement is that the CI-System reads in all config-files (general and job-configs) ONCE at the start of the ci-system. And afterwards a modification of the config-files shall take NO effect!
Do you know whether this is already the case (except I press that button under "manage Jenkins" | "reload Configuration from hard disk" [exact options might sound a little different because I only have a German version here])
Would be very thankful for your help,
Lukas
I run a Git repo to control the config.xml files so have experience of the xml files changing while Jenkins is running.
I can confidently state that Jenkins will not reread the config.xml file unless you specifically ask it to via the UI or cli. In fact if the config is changed via the UI any changes that has been done to the config.xml file will be overwritten with the in-memory version.

Hudson / Jenkins: share parameters between several jobs

I have about 20 jobs using common parameters (user, password), and sometimes the password expires... So I have to change it on all jobs, which is really time consuming (and error prone, I may forget one).
I thought about:
using a kind of magic property file if that exists to have directly lines like KEY, VALUE added into job parameters
adding the same kind of KEY, VALUE pair directly inside build.xml, but where ? And it's really ugly... Maybe with a dedicated XML embedded into the build.xml ?
calling a slave job that would (how ?) push up to the parent one the desired values...
As you can see I'm only starting in Hudson/Jenkins (I'm using Jenkins 1.424.2.2), thanks for your help !
EDIT: I'm not admin of the Jenkins instance, so I cannot have access to global properties...
Go to your Jenkins home and navigate :
Manage Jenkins >
Configure System >
Global properties >
Environment variables > ....
I can think of two approaches:
Use Global properties, found under Manage Jenkins -> Configure system. Here you can define environment variables that should be available to all jobs.
Write a small script that downloads, modifies and posts the job config: http://[jenkinshost]/job/[jobname]/config.xml.
You can read about the api capabilities under http://[jenkinshost]/job/[jobname]/api, here is what it says about reading and changing config.xml:
Fetch/Update config.xml
To programmatically obtain config.xml, hit
[http://[jenkinshost]/job/[jobname]/config.xml]. You can also POST
an updated config.xml to the same URL to programmatically update the
configuration of a job.
I eventually succeeded by:
keeping encrypted credentials in a web page
retrieving them in Hudson thanks to a shell script (wget), decrypt them, and creating a build.properties file in the workspace with lines name=value (in my case ssh.password=...)
This works, because Ant build steps detect this file and pass the variables inside into their context. Thanks to that I could centralize my credentials.

Resources