I'm installing Jenkins via their helm charts. I have a values file set up, and also have some JCasC yaml. I wanted to split up the JCasC into multiple files as the contents of the JCasC bloated the values file too much. I was able to split off multiple CasC.yaml files to another folder, and then load them as a config map to the pod, so that is working.
What I'm having a problem with is the environment variable in the container (CASC_JENKINS_CONFIG). If I try to set this via the yaml, I get an error spec.template.spec.containers[0].env[7].name: duplicate name "CASC_JENKINS_CONFIG". The Config as Code plugin allows for multiple locations of config files, so there must be some way to specify multiple locations to this file.
It seems the Jenkins helm chart is overriding this env variable somehow. Is there a way to set it so that the config As Code plugin looks in multiple locations?
Related
I have a project that I pull from git which has multi modules each module has it's own pom file so how can i use dynamic axis plugin to build multiple modules at once, what I tried is I put the name of modules at parametrized job and used that variable in dynamic axis and got new variable from dynamic axis and I did put the variable in pom.xml place so it became ${modules}/pom.xml and the goal is clean installed. And I cannot use pipeline because my repo is locked with credentials on GITLAB, Any ideas?
I'm using the stable helm chart in order to deploy it in my OCP environment.
I activate the persistence volume where jenkins save the jenkins_home folder.
I found that the helm chart define the plugin and plugin-dir folder as empty volume folder.
It's cause to download the plugins every time when pod is restarted.
How can I configure it that plugin dir will be also configured as persistence volume?
I think the problem lies in this line.
The default value for the overwritePlugins variable is true.
This means that if you do not explicitly set it to false, the ConfigMap that will be generated will create the following line, in an inline script to be executed
rm -rf /var/jenkins_home/plugins/*
Then, and assuming you have elements in the installPlugins list, it will proceed with (re-downloading) and installing those plugins.
Keep in mind that it seems that AFTER installation, plugins seem to end up to /var/jenkins_home/plugins that (assuming you have set a PVC) is a persistent location.
I had a requirment to build a console application, but i need to change some values in appssettings.json file according to the environment and then build it. I am new to jenkins and want to know how to acheive this.
for dev change values in json file and build it -> for test again change the json values and build it -> till prod
This can be done in multiple ways for example (the common idea between these is to check the incoming branch):
You might find better ways to do it but you can use this as a start.
Using bash, jq, sponge through sh step:
Create a json file as a template like the following (consider keeping this file in a version control to clone every build)
# settings.json
{
environment: 'ENVIRONMENT_NAME',
appVersion: 'APP_VERSION'
}
Check the branch name value through if condition and update the template according to the branch value
jq '.environment = "branch_name"' settings.json|sponge settings.json
Use the customized settings.json in your application's code
Using Config File Provider Plugin which can be used inside the Jenkins pipeline as the following (also update it based on the branch name)
configFileProvider([configFile(fileId: 'FILE_ID', targetLocation: 'FILE_LOCATION')]) {}
Check if the application framework can make use of environment variables.
I'm using Jenkins and deploy plugin, with which I'm deploying to tomcat server. How can I pass parameters from properties file to this deploy plugin?
for example I want to pass my property app.server.url to Tomcat URL field.
I tried to pass $app.server.url also %app.server.url%, but that doesn't work.
I am assuming you have a properties file in the format app.server.url=somevalue
You then can inject these properties into the Jenkins environment using EnvInjec Plugin. Use Inject environment variables for your job build step, and just specify your file path (leave the content field blank). After that, you can reference it like this $app.server.url for *nix, or %app.server.url% for Windows. However this only works on the shell level. On the plugin properties level, a lot of plugins are expecting properties only in *nix-style format.
The further problem is that *nix-style variables do not allow dots .. So $app.server.url is not valid on *nix. I do not know if it will work on plugin-level on Windows though.
So after setting up EnvInject plugin, try the following two:
Try using $app.server.url in your deploy plugin.
Else change the property file to something like app_server_url=somevalue, and then try $app_server_url in deploy plugin.
It appears that Jenkins is using the environment variable $JENKINS_HOME for 2 different purposes, and for each purpose it will get a different value.
Purpose#1: First, there is the JENKINS_HOME that is a directory on the local file system that stores files that Jenkins creates. Jenkins uses this directory for disk space to perform builds and keep archive. So a sample value might be:
export JENKINS_HOME=/var/jenkins
That purpose is described here:
https://wiki.jenkins-ci.org/display/JENKINS/Tomcat
https://wiki.jenkins-ci.org/display/JENKINS/Administering+Jenkins
Purpose#2:
There is another instance where Jenkins used the JENKINS_HOME environment variable, and that is for monitoring external jobs. But this time JENKINS_HOME is a URL, like such:
export JENKINS_HOME=http://user:pw#myserver.acme.org/path/to/jenkins/
That purpose is described here:
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring+external+jobs
So it seems odd that Jenkins would use the same environment variable, yet its value will change depending on the purpose. I would think that the external job would use another name for the environment variable, like JENKINS_URL. I suppose as a workaround I can just set the environment variable in the Servlet container (Tomcat for me) instead of on the operating system, so there is no conflict. Still though, the fact that this conflict for the variable exists in the first place seems strange. Is there something I'm missing?
That is pretty confusing, but the second purpose is for monitoring Jenkins jobs in an external process, not within Jenkins itself; so it's not Jenkins that is using the $JENKINS_HOME value in this case and there is no conflict. They could have picked a better name for the variable, though.
In most other cases, the Jenkins master URL is referred to as JENKINS_URL - see the Jenkins CLI documentation for example.