I would like to use the jenkins script console some more.
Where do I have to look in order to find a list of available Objects/Methods that I can use via groovy? Is there something online? Should I browse the source on Github? Where would I start?
Like in this example, how would I have known that hudson.model.Hudson.instance.pluginManager.plugins exists and is ready to be called from the jenkins script console?
println(hudson.model.Hudson.instance.pluginManager.plugins)
Thanks!
You are looking for Jenkins Main Module API.
You may find this answer helpful in getting yourself on your way.
You can enter a groovy script in the script console.
The complete API can be found at the jenkins javadoc.
Related
I'm discovering Rundeck; is there a way to create and run a Terraform process from inside Rundeck?
Thanks in advance
Regards
You can call your Terraform scripts from the command step or the script step on your workflow in the same way you can call any program. Here you can see a complete example of Rundeck+Terraform integration (and about how to automate your deploys).
UPDATE: Also you can test (and collaborate) with this unofficial plugin.
At work we have recently started using Jenkins.
I would like to be able to see the basic status of builds from within Vim.
Is there a typical or standard way of doing this?
Currently i am using my own script which interacts with the jenkins API but it seems unlikely to me that there would be no more common ways of doing something which i think rather a lot of people would want to do.
You can use this vim plugin, which I have developed;
https://github.com/burnettk/vim-jenkins
Since most apps that use Jenkins going forward will use Jenkinsfiles, I decided to use that as the hook. So what you do is add a comment anywhere in your Jenkinsfile with the path to its build plan, like this:
// BUILD_PLAN_PATH: /view/Sweetapps/job/hot-app/job/master
This comment is theoretically useful even apart from this feature as documentation, but its purpose is for the plugin to parse it to figure out how to interact with the jenkins API to fetch the build status (FAILURE/SUCCESS/etc) for the build plan that goes with this Jenkinfile. Once the comment is in place, fetch your build status by running:
:JenkinsShowLastBuildResult
Or its shortcut ("jenkins build"):
<Leader>jb
The build status will be echo'ed into your vim window.
My favorite feature is still Jenkinsfile validation. I use it multiple times a day.
:JenkinsValidateJenkinsFile
or the shortcut (short for "jenkins Jenkinsfile"):
<Leader>jj
Hopefully people like the features, and maybe get some ideas about other features that might be useful to add. Pull requests are of course welcome. I intend to add a feature to open the same build plan that is already documented in the Jenkinsfile in a browser window (using mac "open", but probably if anyone cares to make it work on linux or windows, it would be possible).
I am trying to debug a shell script that is executed via a Jenkins job. The first thing the script does is include another script that is in a completely different repo. My instinct is telling me that the user that Jenkins is executing the script from has access to the directory for the other repo through $PATH or some other similar mechanism, but nothing I’m seeing indicates this.
I’ve looked over variables in http://$host/systemInfo, tried logging on to the Linux box, switched to various users and searched through command history for each, looked at $PATH variable for each, and even tried executing a test shell script with the same include as different users. Still not seeing anything to indicate how Jenkins is able to include a file from a different repo and have not been able to get the include to work in my test script.
My main questions are:
How can I determine what user Jenkins is executing the original shell script as? I would assume user 'jenkins' but I'm not able to get the include to work in my test script executing as this user.
How is Jenkins able to include a script from a different repo?
I'm sure I'm just running into some fundamental Jenkins ignorance on my part but not finding answers. Thanks in advance for any insight.
Finally found the answer and it seems really obvious now that I see it. The Jenkins server that the job runs from has a PATH environment variable defined in the server config in the Jenkins interface. This PATH points to the directory containing the external script.
I want to be able to copy the console log from our build jobs into a SMB dropzone we use for all our builds and started looking at implementing it in Groovy. The problem is that the Groovy Postbuild plugin runs on the slave, but our master is a Unix machine so it's unable to find $(JENKINS_HOME)
Is there a plugin for doing this or any sneaky way of making the Groovy postbuild run on master?
The groovy-postbuild plugin provides access to the build and run objects and those can be used to do what you are asking.
def smbShare = new File('/your/smbshare/location/something.log')
smbshare.write( manager.build.getLogFile().text )
manager.build is a wrapper around the following api:
http://javadoc.jenkins-ci.org/hudson/model/AbstractBuild.html
and there are a couple getLog methods that might be suitable for you.
You'll want to make sure your job user has write access to the SMB share.
How can I schedule a build without tag over Windows, Linux and WCE in Hudson using a shell script and generate a report that will be sent to a specified server?
And so the conditions are :
1. How can I create the build without creating a new tag?
2. How is it possible to excute .sh over windows and WCE (Windows Mobile), is it simply by going through Cygwin? Moreover, having a cross-platform (3 platforms) build does it mean that I must run the build 3 times?
3. How to generate a report and save it in a directory of a server that I'm authorized to access to?
I know that I asked many questions at once. It is because this is my first use of Hudson and these are kind of details. Moreover, I don't want to make a mistake by creating new tags during my tests. The 1st and 3rd questions are the most important. If anyone gives me the right answer to them, I'll choose it as the right answer.
Thank you a lot.
first, people nowadays mostly use jenkins instead of hudson (open source, better support)
build can be started manually in hudson / jenkins, just click the green arrow. It will create a new build but won't change your repository (unless the last step of your build is creating a tag, in that case, just remove that step for testing)
Usually, .sh scripts run in shell excecutables (ash, sh, bash, csh...) and are not supported of the shell on windows. You'll have to go through cygwin or have a platform specific build command
kind of not clear for me. If you use jenkins to build a matric build (with the matrix axis being your target platform), you'll have automatically a nice report in jenkins itself (status of each build). You can keep artifacts (use post-build action : archive the artifacts) or use another plugin to publish the file you like (exemple : ftp reporting)
Sorry not being able to be more precise, that's how far I understand your questions.