lockable-resources-plugin icon indicating copy to clipboard operation
lockable-resources-plugin copied to clipboard

[JENKINS-31437] attach properties to resources, inject properties at build time

Open McFoggy opened this issue 9 years ago • 22 comments

This PR allows to define properties, a list of key/value pairs, attached to each resource. On the project then you can decide to receive (as build parameters) the properties of the elected resources.

I use this feature to define named pools of resources that I can then use at build time. Especially, by product family (named pool) I am able to define resources and for each I define for example the host name, host ip, communication ports, ...

image

McFoggy avatar Sep 25 '15 07:09 McFoggy

I created JENKINS-31437 to track and ask for inclusion of this PR.

McFoggy avatar Nov 06 '15 17:11 McFoggy

This would be great!

prediktorn avatar Feb 24 '16 14:02 prediktorn

Should this be updated to comply with Pipeline step?

nick-rumyantsev avatar May 16 '16 15:05 nick-rumyantsev

@izzekil do you have pointers/link to plugins code/repos to comply to that?

McFoggy avatar May 17 '16 06:05 McFoggy

Very excited about this. Lockable resources with relevant properties is exactly what I'm looking for.

ajithhub avatar May 31 '16 21:05 ajithhub

this would be super awesome, waiting for this to be released :smile:

aneesh-joseph avatar Jun 04 '16 05:06 aneesh-joseph

Any news on when or if this will be released?

itsamenathan avatar Nov 30 '16 20:11 itsamenathan

OP any thoughts about merging?

aldialimucaj avatar Mar 09 '17 13:03 aldialimucaj

Would like this too

lachiemurray avatar Jul 03 '17 14:07 lachiemurray

Looks neat, but has to be rebased/re-merged against current master branch.

On a side note: would it be a big further leap to also publish the resource instance's assigned labels, the labels which matched for the current selection, and the description (all as string variables, perhaps named with the base-name user requested for storing the name of the resource instance plus some suffix?) I guess not, after all the work done here? It would nicely address several open issues/feature requests...

jimklimov avatar Nov 14 '17 20:11 jimklimov

FWIW, I posted https://github.com/McFoggy/lockable-resources-plugin/pull/2 against @McFoggy 's branch to bring this codebase up to date against master. The best test of the update I could do is for it to be compilable and successful with mvn test; conflicts were resolved in a way which made sense to me by logic - but not sure how correct the resulting Java is (ain't my native tongue).

jimklimov avatar Nov 14 '17 22:11 jimklimov

Hi there, as it was long requested I reworked this PR to rebase it, add pipeline support and introduce some integration tests.

You can now, additionally to standard usage, use properties inside a pipeline job:

echo 'Starting'
lock(label: 'RES', quantity: 1, injectProperties: true) {
  echo 'injected id: ' + env.id
}
echo 'Finish'

added parameters:

  • injectProperties: true/false, controls if resource properties are merged inside the step environment variables
  • prefixProperties: true/false, if true and if variable parameter exist then injected properties will be prefixed with the value of the variable followed by an underscore.
    • given the resource r1 {label: 'RES', properties: {'id':'prod'}
    • defining step lock(label: 'RES', quantity: 1, variable: 'kind', injectProperties: true, prefixProperties: true)
    • will make the injected id property accessible under: env.kind_id
  • uppercaseProperties: true/false, controls if resource properties keys are put upper case

Even for standard builds I added the possibility to prefix & uppercase the injected properties. image

McFoggy avatar Feb 21 '18 08:02 McFoggy

I need some more time to review what makes the tests fail.

McFoggy avatar Feb 21 '18 08:02 McFoggy

tests are fixed.

McFoggy avatar Feb 21 '18 09:02 McFoggy

@amuniz any chance to get a review?

McFoggy avatar Feb 28 '18 07:02 McFoggy

@amuniz @abayer may I please request some feedback (positive or negative) on this 2.5 years old PR?

McFoggy avatar Mar 08 '18 10:03 McFoggy

:+1: Would love to see this get merged...anything I can do to help?

kddubb avatar May 21 '18 18:05 kddubb

anything I can do to help?

provide some help to keep it up to date? I am a bit out of time to keep the PR aligned with master until it got merged.

McFoggy avatar May 22 '18 05:05 McFoggy

I tried to give the resync a shot in updating my PR https://github.com/McFoggy/lockable-resources-plugin/pull/2 but there are quite a few conflicts I'm not qualified to make heads or tails of and resolve logically properly :)

Although it seems you've rebased your commits with newer pipeline-compatible code, so my earlier PR actually grows from a different revision of your work that's no longer in the current branch's git tree, right?

Currently the branch my PR is made from is your older codebase synced up with current upstream/master.

jimklimov avatar May 22 '18 07:05 jimklimov

there are quite a few conflicts I'm not qualified to make heads or tails of and resolve logically properly :)

That's why I also can't maintain unmerged by myself my PR in synch with upstream that is constantly evolving (which is normal).

that's no longer in the current branch's git tree, right?

you're right. Thanks for the trial anyway.

McFoggy avatar May 22 '18 08:05 McFoggy

when is it going to be merged? thank you

theearthwanderer avatar Apr 27 '20 20:04 theearthwanderer

I will be taking a look at this merge request. It's quite old and cannot easily be rebased so I'll submit it as a new branch based on this one.

gaspardpetit avatar Feb 05 '22 21:02 gaspardpetit

close as it is trimmed to a lot of other PRs and this one will be no more possible to merge (due many of conflicts)

mPokornyETM avatar Nov 06 '22 23:11 mPokornyETM