![]() ![]() When that issue is closed, the plug-in should work fine with Pipelines, DSL, timers, cron, REST-API-triggered jobs, etc.Īctive Choices parameters allow users to select value(s) for a job parameter. Follow JENKINS-63284 for updates on a version that does not require the UI. We navigate the DOM using JavaScript to create the relationship and reactivity between parameters. NOTE: The plug-in was developed in a way that it relies heavily on the HTML/DOM of the Jenkins UI. When configuring jobs with this feature, keep in mind how the parameter will be rendered and whether it could be a security issue. NOTE: The Reactive Reference Parameter allows for parameters to be displayed as formatted HTML. Active Choices Reactive Reference Parameter.Once the plugin is installed, three new parameter types become available: These custom scripts support the use of the Jenkins Java API, system environment variables, global node properties, and potentially external Java and Javascript libraries. Active Choices parameters can be dynamically updated and can be rendered as combo-boxes, check-boxes, radio-buttons or rich HTML UI widgets.Īctive Choices parameters are scripted using Groovy, or (optionally) Scriptler Groovy scripts. This populates the select list.įinally add a simple Pipeline Script to output the the OCID of the selected compartment.The Active Choices plugin is used in parametrized freestyle Jenkins jobs to create scripted, dynamic and interactive job parameters. Assemble Hash Map of compartments with return and display values ![]() Proc.waitForProcessOutput(sout, serr) //Wait for command to completeĭef Object jsonResp = parser.parseText(sout.toString())ĭef compartments = new HashMap() //A HashMap is list of key/value pairs Assemble OCI CLI command to fetch compartmentsĭef cmd = "$oci iam compartment list -c $tenancy_ocid -compartment-id-in-subtree true"ĭef proc = cmd.execute() //Execute OS command Pull in credentials, filter out the secret containing the tenancy OCID, and return the secret text.ĭef tenancy_ocid = .CredentialsProvider.lookupCredentials(Ĭom.class,ĭef oci = '/var/lib/jenkins/bin/oci' //oci command shortcutĭef sout = new StringBuilder(), serr = new StringBuilder() //standard out and error strings Now click the Groovy Script radio button and add the following Groovy script: import compartment) and make it a Single Select choice type. The JobĬheck This project is parameterized, and select the Active Choices parameter. We’ll fine-tune this command in the Groovy script later. This should result in a JSON list of compartments. Test the CLI functionality by logging into the command line on the Jenkins server and run /var/lib/jenkins/bin/oci -profile DEFAULT iam compartment list -compartment-id You could simply add id in plain text to the Groovy script below, but I chose to store it in a Jenkins Secret Text credential. To fetch the compartments, the CLI command requires the Tenancy OCID. In my case, I installed the CLI client in /var/lib/jenkins/bin.įor further CLI info check out OCI Command Line Interface (CLI) Basics. The installation is fairly easy when using the Quickstart guide from Oracle. INSTALLBUILDER CHOICEPARAMETER VALUE INSTALLTo do this, simply install the CLI client as the Jenkins user. The OCI CLI client needs to be accessible by the Jenkins user on the server. I then populate an Active Choice parameters with the key/value pairs of compartment name and compartment ID, so that the ID is passed along to the Jenkins pipeline. To do this I invoke the OCI CLI command line client to fetch the list of compartments. For my requirement I needed to populate a choice parameter (select list) with the list of compartments from my Oracle Cloud Infrastructure tenancy. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |