Is there a way to inject a script tag in browsermob-proxy if it does not already exist? - browsermob-proxy

I would like to use browsermob-proxy with selenium and inject a script tag IF it does not already exist. Is this possible using javascript?

Related

Jenkins to trigger another build/project dynamically

Is there a way in Jenkins to trigger another build/project dynamically based on a parameter value in parent project?
The reason for this is that I have 100's of projects and I don't want to use pipeline/conditional post build plugins to link all jobs.
I know of a way using REST API but trying to find is there a way to trigger a single project from those 100?
Easy with Pipeline Plugin. Just define your parameter (say MY_DOWNSTREAM_JOB) and use it inside the groovy script definition:
build MY_DOWNSTREAM_JOB

How to get custom metrics into jelly for email-ext?

Using Jenkins and email-ext, I have copied the "html" template and made it look the way I want for our build mail.
What I'd like to do now is get some custom metrics in the build mail. Specifically, our build jobs call a number of PHP scripts that perform work. One of these scripts creates a bunch of files in a directory. I'd like to have our build mail have an output line like:
The super cool script created 8 files for your enjoyment.
The PHP script knows it created 8 files, of course. How could that script get that number in a place where Jelly could know it and output it? Is there a way to have Jenkins store such things and make them available to the Jelly template?
Use the EnvInject Plugin https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
Set the Enviroment variable in your PHP script
Output the Environment Variable in your Email-Ext
If the files are created in a specific directory - so counting the number of files in a folder is good enough -, you could try something like this in your jelly template (note: I didn't test it):
<j:set var="filesCreated" value="${build.getWorkspace().child('path/to/result/dir').list().size()}"/>
The super cool script created ${filesCreated} files for your enjoyment.

Custom url plugin for Jira

Is it possible to make a plugin for Jira that behaves as custom url?
For example, suppose if I have jira on http://jira.example.com and I want to get some data from e.g. http://jira.example.com/record/{id}, where id is parameter for plugin. And output data is audio stream.
You can create a JIRA plugin with a REST module to display arbitrary content with a URL similar to the following:
http://jira.example.com/rest/record/{id}.
If you prefer, you could write it as a straight servlet module instead, with a URL such as this:
http://jira.example.com/plugins/servlet/record/{id}
If you want to expose an endpoint at the main http://jira.example.com/record level, I am not aware of any way to do that within a plugin. (It should be possible, albeit not very portable, by editing the configuration files in the JIRA program directory.)

How can I access a file in my Grails plugin from a src file in the same plugin?

I'm working on a JavaScript testing plugin for Grails. I wrote some Groovy classes to perform the testing that I've stored in my src/groovy folder. I hook into the testing events in my plugin's _Events.groovy script and inject an instance of the test runner. From that instance of the test runner, I need to access the JavaScript files, which I've stored in src/js, to perform the testing.
The plugin documentation specifies a way to get the path from my Gant scripts, but that doesn't work elsewhere. I've also tried to get access to the GrailsApplication via grailsApplication or ApplicationHolder, but I get null. Finally, I've tried accessing BuildSettings and ConfigurationHolder, but those show me an empty configuration.
To make my plugin work, I am currently copying the JavaScript files into the application's test/resources folder so it's in a known location relative to the working directory, which I'm assuming is the project folder. This feels invasive and fragile to me, so I'd like to figure out a "right" way.
How can I get a path to my plugin from my test runner so I can find those files?
If you have the BuildSettings and the pluginManager bean (either dependency-injected with def pluginManager or via PluginManagerHolder) then you can get the path with
new File(buildSettings.projectPluginsDir, pluginManager.getPluginPath('foo'))

Grails run-script with argument

I want to create grails script which adds an admin account to my application. Something like:
grails run-script utils/adminAdd.groovy username password
Unfortunately, it seems like run-script doesn't support passing arguments to scripts (allowing one to run multiple scripts at once, instead).
Anyone knows a workaround?
This should be supported, so you should create an issue at http://jira.grails.org/browse/GRAILS
In the meantime I think to keep backwards compatibility you probably need a way to differentiate script names from args, e.g. a prefix:
grails run-script utils/adminAdd.groovy -Jusername -Jpassword -Jfoo=bar
Then run-script could split out the args list into un-prefixed script names and send the de-prefixed args to each script as it runs.
Once you get it working locally send a pull request or attach the updated script to the JIRA and it'll get fixed a lot quicker.
See my answer to How can I run a Groovy class from the command-line within a Grails environment?
In short, you need includeTargets << grailsScript("_GrailsArgParsing") in your script; see documentation for more options.
If anyone is still looking for a ready solution, here it is.
I solved this issue by digging into the grails-2.x/scripts/RunScript.groovy. Then I made myself a new script called RunSingleScript.groovy, which accepts arguments, instead of the original list of scripts.
I believe this code could be re-written to something like what Burt suggested, and make it part of the core RunScript.groovy. I am lazy, and kind of busy, so I made a custom script which does the job.

Resources