Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced CARTRIDGE_CLONE_URL from String to ExtensibleChoiceParameter… #32

Merged
merged 1 commit into from
Feb 22, 2017
Merged

Conversation

DavideVi
Copy link

… so that the cartridge list can be dynamically loaded.

I've added a Groovy script in the ExtensibleChoiceParameter which loads a list of cartridges from "https://raw.githubusercontent.com/Accenture/adop-platform-management/master/cartridges.txt" and presents them to the user.

In addition, every time that list is loaded, a backup of it is saved in "/var/jenkins_home/userContent/cartridges.txt", just in case the list provider is ever down. (Obviously all these parameters can be changed so that they point to different providers, so the list of cartridges won't necessarily be hosted in the same place as the cartridges, as is the case currently with GitHub).

In addition, because we are using the ExtensibleChoiceParameter plug-in, a user can now specify a custom cartridge URL without having to modify the job.

def loadCartridgeCollectionJob = workflowJob(cartridgeManagementFolderName + "/Load_Cartridge_Collection")


def loadCartridgeCollectionJob = workflowJob(cartridgeManagementFolderName + "/Load_Cartridge_Collection")/var/jenkins_home/userContent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this "/var/jenkins_home/userContent" be here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean Load_Cartridge has to be run on master as it depends on the file system?


return catridges_list;
}
catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be a bit more explicit about the exceptions being caught. This may aid debugging in the future.

@DavideVi
Copy link
Author

DavideVi commented Feb 7, 2017

Implemented @kramos's request for a package manager system for cartridges.

This PR now depends on the following PRs:
Accenture/adop-jenkins#31
Accenture/adop-docker-compose#188

@DavideVi
Copy link
Author

DavideVi commented Feb 7, 2017

Testing:

  • Tested if it works with multiple semicolon-separated URLs
  • Exception handling added for invalid URLs
  • Exception handling added for invalid YAML files

Copy link
Contributor

@dsingh07 dsingh07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. A few minor quirks:

  • May need to be careful of the dependency on the snakeyaml package (in the unlikely event they deprecate it)
  • I have noticed a weird error sometimes in choice parameters populated by dynamic scripts, where the first time you run a job via "Build with Parameters", the script does not run and the dropdown appears empty, and then you basically configure the job, but not make any changes and then save, and then the parameters are magically populated. Have we encountered this issue on a fresh ADOP instance with your platform-management repository loaded in?

Other than that, it looks good to me!

I'm assuming this PR has a dependency on Accenture/adop-jenkins#31 and Accenture/adop-docker-compose#188 to be merged in first.


if (URLS == null) {
return ['[ERROR] CARTRIDGE_SOURCES Jenkins environment variable has not been set'];
println "[ERROR] CARTRIDGE_SOURCES Jenkins environment variable has not been set";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Println should be before the return as the branch will never execute.

Also, if URLS is equal to "" we should probably return.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me (comments given in person on the error message and yaml format).

@dsingh07 I coulnd't replicate this at all. I opened ~30 browser and every single one behaved. Are you able to replicate?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kramos It isn't anything to do with the browser session, it's the first time you try and build with parameters on a fresh ADOP Jenkins, where the population script has never been evaluated. I haven't personally tested it with this plugin, but it maybe an issue specific to the plugin I was using since I've only ever seen it happen with Dynamic Choice Parameter.

@DavideVi
Copy link
Author

DavideVi commented Feb 9, 2017

New YAML format:

adop-cartridge-java:
name: "ADOP Java Cartridge"
url: "https://github.com/Accenture/adop-cartridge-java.git"
adop-cartridge-cartridge-dev:
name: "ADOP Cartridge Development"
url: "https://github.com/Accenture/adop-cartridge-cartridge-dev.git"
adop-cartridge-chef:
name: "ADOP Chef Cartridge"
url: "https://github.com/Accenture/adop-cartridge-chef.git"
adop-cartridge-docker:
name: "ADOP Docker Cartridge"
url: "https://github.com/Accenture/adop-cartridge-docker.git"
adop-cartridge-aspnet-linux:
name: "ADOP ASP.NET Linux Cartridge"
url: "https://github.com/kramos/adop-cartridge-aspnet-linux.git"
adop-cartridge-flyway:
name: "ADOP Flyway Cartridge"
url: "https://github.com/kramos/adop-cartridge-flyway.git"

And small changes to how the YAML is parsed:

yaml.each{ key, cartridge ->
cartridge_urls.add(cartridge.url)
}

@kramos
Copy link
Contributor

kramos commented Feb 9, 2017

Tested and looks good to me.

… so that the cartridge list can be dynamically loaded
@nickdgriffin
Copy link
Contributor

LGTM!

One thing that has now occurred to me is that we aren't taking cartridges from Gerrit any more with this, perhaps we need to remove that functionality? Alternatively, we can still do that but place the equivalent cartridges.yml within userContent for people to switch over too if they don't want to come straight from GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants