Jenkins Pipeline : How to access plugin contributed Global Configuration values - jenkins-pipeline

I'm working on a Jenkins Pipeline script and ran into a case where I need to get a value that is set in the Jenkins Global Configuration. The Manage Jenkins : Configure System page is where I set a value for one of the plugins installed. The plugin provides a configuration line to add a URL (Confluence URL). I want to access the URL in my pipeline to use for a specialize step. The issue I'm having is I'm unsure how to get a global configuration defined by a plugin. Is there a way to access global configuration values from a pipeline? Or would the plugin have to expose it?

Related

XrmToolBox PluginRegistration. Edit Plugin Step Configuration from plugin code

How can I modify the Unsecure and Secure Configuration in plugin code for step?
For example, I have a plugin and I will send it to my friend. I want this plugin to clean or modify all information that my friend has in his XrmToolBox Plugin Step Secure Configuration field and add mine (for me is necessary to add mine config in this field). Can I do it from code in my plugin?
Let's make the things straight.
CRM Plugin is an executable code logic for extending the platform execution pipeline like do something (ex. Assign/Update) after something (ex. Create/Update) happens.
Plugin registration tool (PRT) is useful for registering the Plugin assembly (dll) & steps to execute per our expectation.
Secure/Unsecure config for Plugin step is just like web.config in our web application. Read more
You want to configure certain key/value pair, for example - some external web service credentials, then put it in secure config of that particular plugin step using PRT, so that you can consume it inside the plugin step code logic.
We will not update the secure config from the plugin code, rather we will just consume it.
If you are shipping your environment plugin steps to your friend environment, then give the plugin assembly & step as a solution package, once the solution is imported in your friend environment - the XrmToolBox PRT will show the changes. Or connect the two environments in different PRT sessions & verify the differences for config merge process.
If you want to develop a console app or something to do the deployment for you, read the below link:
Programatically Updating the Secure Configuration of a Plug-in Step

Maven build uses an HTTP proxy.. that I haven't configured

I was able to build Maven projects from command line with no issue for as long as I can remember.. But this morning, I am getting some error like it's trying to use the company HTTP proxy to fetch dependencies and it requires authentication.
We have internal Nexus repositories, so I reallyt don't get why all of a sudden, it tries to go outside.
I checked my M2_HOM/conf/settings.xml, and no proxy is defined there. I checked my env variables, and I don't see anything declaring a proxy either.
Where can it possibly get configured then ?
Thanks
OK, after couple of hours of struggle, I found the problem.
2 weeks back, I needed to install locally a Logstash plugin that wasn't available internally. This required me to fiddle here and there with my config, to allow Logstash to actually go through the proxy and fetch the required dependency - and it involved Maven, as I used the ugly workaround given here : https://github.com/elastic/logstash/issues/2851
As explained in the link, I defined the proxy for logstash plugin in $HOME/.m2/settings.xml .. and forgot to remove it after ;-/
I found this by running the build in debug mode (-X option) and this file was referenced at the beginning.

Jenkins maven release -- How can I access the tag URL in a post-build task?

I need to be able to access the tag URL that is created (the developerConnection) after a maven release.
I can access the MVN_RELEASE_VERSION, but some of our dev teams just use that as the tag version, and some teams prepend the artifactId, and I really have no way in Jenkins of knowing which projects use which mechanism, so I can't assume that the URL would or wouldn't have the artifactId included.
There doesn't seem to be a definitive list of which variables are available from the release plugin, but does anyone know of a variable I could use to capture this information?

Travis CI api requests overrides the keys

I have a default config set in .travis.yml for one of my git repos. I want to trigger this repo build through the Travis CI api. I'm able to do this successfully. But when I want to add additional parameters like environment variables in the api, it is simply overriding the environment variables in this dependent build.
https://docs.travis-ci.com/user/triggering-builds
Could some one please help how I can add environment variables in the api without having to override the original ones.
I got the confirmation from Travis CI team that keys will always be overridden. Below is the message.
Unfortunately I think that this is a limitation of the API at the moment, but I will open an internal issue to investigate it further. One way to help with this would be to move global environment variables to the repository settings, please see https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings for more details.
*

Disable Maven deploy post build action in a Jenkins (test) instance?

For testing purposes I sometimes copy some Jenkins jobs from a produtive instance into our testing instance.
Repositories, branches etc. are controlled by environment variables but I want to block the "Deploy artifacts to Maven repository" post build action for all jobs in this Jenkins instance.
Any idea how to do this?
There is a Jenkins plugin for conditional build steps: Conditional Build Step Plugin. While plugin supports a variety of condition types, for reference here simple use of toggling deployment via global Jenkins property used in a boolean condition.
Property can be defined as Global Property in Jenkins configuration (Jenkins home > Manage > Configure: Global Properties)
As example lets say you have defined a property with name doMavenDeploy:
production environment: property value is true
test environment: property value is false
job configuration would need to be modified to add a Conditional build step with :
Run? : Boolean condition
Token : $doMavenDeploy
Step to run if condition is met : add maven deployment there.
In that way you would need to modify your jobs once, after modified configuration is active you can move them between both servers without impacts.
There are other alternatives possible depending on specifics and constraints in your projects:
introduce different maven profiles for 'normal' and test builds and control activation via environment variable, file present or similar
if you use artifactory/nexus or similar: configure test server without deployer credentials

Resources