Modify chef role attributes from jenkins - jenkins

I would like to update a chef role attribute from Jenkins.
The knife command:
Knife role edit role-name
Appears to open a text file from a defined editor where changes can be made and then saved. This doesn’t seem like a feasible solution from Jenkins. Are there any options for achieving this?

You can manage your roles using "role cookbooks" and then manage the role attributes using the recipe therein from jenkins. Refer to this link for "role cookbooks"

i strongly advise you not to let the build server (jenkins in your case) to push any changes to the repository. the repository is a source of truth, don't let any automation break\modify it.
to my understanding, it feels like there is some other pretty solution.
note that, chef-client has support for in-line attributes (--json-attributes), which you can utilize to override an attribute and make decisions in your recipe based on the value of that attribute.

Thanks for your responses. The solution I went with was to call
knife role show role-name
persist the output and update the attributes I wanted to modify using jq. Then, update the role using the updated json using
knife role from file FILE
I hope this help someone else in the future.

Related

Jenkins - getting "No type prefix:" when assigning roles

I am trying to assign roles to users in Jenkins using the 'role based strategy' plugin. When I do that, I am getting a red text that says "No type prefix:" in front of every user that I am assigning a role to. Please advise how this can be removed.:
I am very new to Jenkins so any suggestions will be very helpful.
Regards
Ramesh
use "USER:" for user and "GROUP:" for group .. eg "USER:ABC" ..this changed with the recent plug in update ..
In order to resolve we have to add twice.
In your example
Under Global roles
Enter only jenkins and click on Add and click on admin checkbox
Enter USER:jenkins and click on Add and click on admin checkbox
Apply
Save
Similarly for all other users which needs admin role can be mapped.
The same approach can be used under Item and Node roles if it is configured
By doing this we would still see > No type prefix: jenkins however role based permission would work in desired way.
If you are locked out then use following link to get access again-
https://www.jenkins.io/doc/book/security/access-control/disable/
and follow above steps.
Just update plugins:
Matrix Authorization Strategy Plugin
Role-based Authorization Strategy

Redmine plugin activation

I'm developing a Redmine plugin, and I want to add a custom field programmatically when I'm activating my plugin, but i don't find the plugin activation method in the core Redmine, which I want to wrap.
Can anyone help me?
Well, I am not really sure what you are looking for as a Redmine plugin is something that you don't really activate as Redmine user at runtime.
Your plugin is 'active' and will be loaded on Redmine start when it resides in the plugins folder.
The first executed code is in the init.rb of your plugin.
Also you should clarify what you mean by "add a custom field":
create a new custom field
add a custom field to a tracker and/or project
create a new custom field type
Maybe you should elaborate more in detail on what you are trying to achieve.
Just came to my mind:
If by 'plugin' you mean 'project module' (which is in fact something you can (de-)activate) then you probably should patch the project class and add an after_save hook where you check if your project module is active and program your actions accordingly...

Set a file path from Jenkins' choice parameter

I struggled few days, But still, I could not find a solution for this.
I am trying to deploy Marathon apps with Jenkins and follow this tutorial.
https://docs.mesosphere.com/1.10/tutorials/deploy-on-marathon/
I want to configure a parameterized project for this. Eg :
Builder can select one choice out of four choices.
As an Example: Suppose the user has selected the vault option.
Then I need to change the file name(Definition File) base on what user has selected on above options.
I am using Marathon deployment plugin.
For this configs I am getting below error :
18:12:40 [Marathon] Application Definition not found:
18:12:40 [Marathon] Could not find file 'deployment_files/"($CONTAINER)".json'
18:12:40 Build step 'Marathon Deployment' changed build result to FAILURE
Could you please help me to achieve this problem or suggest a better way to do this?
When referencing a build parameter in another setting (or another parameter) the way you are trying to, I typically use the following format:
deployment_files/${CONTAINER}.json
There is some good reading to be done in the following thread on using $VAR vs ${VAR}

How to set chef data bag values via Jenkins?

I posted "How to set chef attributes via Jenkins?" which was answered correctly, that is, using the "-j" option. However, what if I want to set the load version in the data bag in Jenkins so ALL cookbooks can use it? That is I don't want to use the "-j" option and instead search the value in the data bag? How do I do I set chef data bag values via Jenkins
Best way: use knife commands to upload predfined or generated databags.
knife data bag from file BAG json_file_for_item
the file must have a defined format, extended documentation is HERE
There's requirements on the file system hierarchy and on the file format, copying the doc here sounds a bad idea.
In addition to knife, you can also write your own scripts using the Chef REST API. There are clients for Ruby (Chef-API), Python (PyChef), JavaScript (chef-js), and many others.

Renaming JIRA Issues

Is it possible to rename an issue for a given project in JIRA?
For example, if I have a project named equities and I create an issue from the JIRA GUI, the new issue is named something like equities-1.
Could I rename the issue to something like equities_1.0.0?
I am trying to create a release management workflow in JIRA and need to enforce strict naming conventions. Hence, why I need to change the name.
Sorry but you can't.
What you are calling a "name" is indeed a key automatically generated by JIRA :
[PROJECT_KEY]-[SEQUENCE_NUMBER].
You can never change it.
For your release management workflow, I think you should try another field :
"summary" field,
or why not a brand new custom field,
or use the "fix_version" field
I hope it helps

Resources