gradle-jenkins-plugin icon indicating copy to clipboard operation
gradle-jenkins-plugin copied to clipboard

workflows and good practices

Open feyrob opened this issue 8 years ago • 1 comments

Without having used GJP before, I expected a workflow similar to this:

  • make local change to gradle build file
  • test, review, ... (possibly go through repo:dmz)
  • push change to repo:master
  • master_jenkins updates to latest in repo:master

If I understand correctly, this is not possible with GJP. Once the gradle build file has been updated to represent the target state, GJP is not 'aware' of removed jobs anymore.

Is there a good known practice for removing old Jenkins jobs when using GJP?

I can imagine some weird workarounds (e.g. execute task:deleteJenkinsItems with previous version before executing task:updateJenkinsItems with new version), but I think it most likely that I simply have not identified a good workflow yet which other people are already exercising.

What are good GJP workflows and practices? Are there accessible GJP installations that could be looked at to learn about working practices?

feyrob avatar Apr 29 '16 18:04 feyrob

I'm learning the GJP too but your issue made me curious. So far, the GJP works the way I expect it to, within the boundaries of how I know jenkins works.

My answer to your question would unfortunately be "it depends on what you change"

The GJP doesn't do anything special regarding keeping track of the jobs it has created. So for example if you change something in the build.gradle file that alters the project name, then there neither gradle, nor jenkins understands that you may wish to rename an existing job. It will instead create a new job with the new name and leave the old job behind.

You will hit another problem if you try to change the job type for example. Jenkins will return an error saying that the job already exists. There is no way to change the job type once the job is created. You need to delete it and create a new one if you wish to use the same project name.

Workflow-wise, unfortunately, I don't have any good recommendations what you can do to fix this in a nice way. I think you already hit upon the obvious one that you checkout the older version of the build.gradle file that created the jobs and run deleteJenkinsItems.

Alternatively, I think that I am more in favour of implementing some type of job versioning that you can add as metadata in the description field, and have a separate cleanup job that sweeps away anything that is not the latest version (or some other smarter formula). Since that cleanup job is just script with an arbitrary level of complexity, you could make it as aggressive or permissive as you like.

philbert avatar May 03 '16 08:05 philbert