Hi Petr,

You're a legend :-) Your advices worked, comrade. Thanks a million!!

I didn't use Job DSL, Jenkins.instance.reload() appeared to be all I needed 
to make changes effective (project and global address).
I put "z_" prefix for the reload script to make sure it's run in the last 
turn - that's how it's defined in docs, and that's how it really worked.

Regarding RabbitMQ - it appeared that if you set a PLAIN password in 
config.xml that you use to create the job instance, it works like a charm.

Thanks again!!

Regards,
Kirill.


четверг, 20 октября 2016 г., 9:28:03 UTC+1 пользователь Petr Archakov 
написал:
>
> Hi Kirill,
>
> I am now sure, if all of these will work in your particular use case, but 
> I was able to achieve all three points mentioned programatically with 
> Groovy script in init.groovy.d. Although I'm using Jenkins 2.x, I expect 
> it also should work with older versions.
>
> 1. I use Job DSL plugin for this. Just place following script to 
> init.groovy.d:
>
> import javaposse.jobdsl.dsl.DslScriptLoader
> import javaposse.jobdsl.plugin.JenkinsJobManagement
> def workspace = new File('.')
> def jobManagement = new JenkinsJobManagement(System.out, [:], workspace)
> new DslScriptLoader(jobManagement).runScript("job('test')")
>
> 2. One option would be to try Jenkins.instance.reload(). I achieve this 
> by running following script in init.groovy.d:
>
> def locationConfig = 
> Jenkins.instance.getDescriptor('JenkinsLocationConfiguration')
> locationConfig.setUrl("<YOUR_LOCATION>")
>
> 3. Again, Jenkins.instance.reload() might help. Jenkins actually uses 
> master key (which is different for every setup) to encode passwords. If you 
> configure RabbitMQ programatically, you can put a proper hash right away 
> with:
>
> new hudson.util.Secret("<PLAIN_TEXT_PASSWORD>")
>
> Hope it helps.
>
> Cheers,
> Petr
>
>
>
> On Wednesday, October 19, 2016 at 6:21:56 PM UTC+2, Kirill wrote:
>>
>> Hi noble Jenkins developers,
>>
>> I am trying to fully automate my Jenkins-based job execution environment 
>> and facing some issues there. I still have to do some steps manually :(
>> My base image is 1.651.3.
>>
>> 1. I need to have a job preconfigured. Tried different ways, the best one 
>> seems to be creating one programmatically from XML via Jenkins API, in 
>> Groovy script placed in *init.groovy.d*. However, even if job was 
>> created (no errors given, and object hash is available in debug), sometimes 
>> Jenkins needs to be reloaded in order for it to appear :(
>> 2. I have slaves populated via Swarm plugin. The problem is that slaves 
>> do not connect until I go to the global Jenkins config and press "Save" - 
>> otherwise slaves complain about Jenkins not having the URL configuration 
>> available yet. I cannot think of a way to make it fully automated. How is 
>> it possible to define this URL before Jenkins start?
>> 3. I have a hashed password for RabbitMQ connection set in my config.xml. 
>> When this XML is used to create a job, RabbitMQ rejects the attempts to 
>> connect with the password provided saying it's "plaintext". However, 
>> connection validation in a job UI config form works fine. All that is 
>> needed is to open the config and save it. Looking at the config.xml I see 
>> that the password hash has changed. How to get around this without the 
>> manual config saving? Programmatic .save() doesn't help :(
>>
>> Regards,
>> Kirill.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/ab230862-369a-4997-8319-a5e4665ccd74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to