jenkins-scriptler

cloudbees, groovy, jobs, folders: How to determine the job result, if the job is within a cloudbees folder?

孤街醉人 提交于 2019-12-06 16:00:09
Problem : I'm using a script to determine if a certain amount of jobs are in SUCCESS state. It worked fine as long as I was not using cloudbees folder plugin. I could easily get the list of projects and get the project result. But after I moved the jobs to the cloudbee folder, the jobs and therefore the job results are no longer available! Q : Does anybody now how to get the job results with groovy from jobs which are located in a Cloudbees folder? Jesse Glick def job = Jenkins.instance.getItemByFullName('foldername/jobname'); Folder plugin provides the getItems() method which can be used to

jenkins remoting callable on slave using groovy

你离开我真会死。 提交于 2019-12-06 12:33:16
问题 I was trying the remoting code to communicate with a jenkins node via the groovy shell. Here is the bare code which I ran: import java.io.IOException; import java.lang.String; import hudson.remoting.*; import java.io.Serializable; Callable<String, IOException> task = new Callable<String, IOException>() { @Override public String call() throws IOException { // This code will run on the build slave return "Testing"; } @Override public void checkRoles(org.jenkinsci.remoting.RoleChecker checker)

How to change a Git URL in all Jenkins jobs

一笑奈何 提交于 2019-12-06 03:11:26
I have more than 100 jobs in Jenkins and I have to change a Git URL in each and every job since we changed the git server. I must traverse each job and change the Git URL. Can anyone help me with a groovy script? I was able to traverse each job, but not able to get the Git URL or change it: import hudson.plugins.emailext.* import hudson.model.* import hudson.maven.* import hudson.maven.reporters.* import hudson.tasks.* // For each project for(item in Hudson.instance.items) { println("JOB : " + item.name); } I badly need help in this, please someone help me. The script below will modify all Git

Replacement for Jenkins Scriptler plugin?

妖精的绣舞 提交于 2019-12-05 17:02:05
It looks like the Jenkins Scriptler plugin is no longer available, due to security reasons: https://wiki.jenkins-ci.org/display/JENKINS/Scriptler+Plugin "Distribution of This Plugin Has Been Suspended" Is there a similar plugin that I could use to run saved Groovy scripts? Hi you can store your groovy scripts in Managed Files and pass the parameters to groovy script through Extended Choice Parameters Plugin. Or else you can download Scriptler plugin source code and add it to your /var/lib/jenkins/plugin folder and start Jenkins server. It will work fine. 来源: https://stackoverflow.com/questions

Working with jenkins credentials

╄→гoц情女王★ 提交于 2019-12-05 01:07:24
I want to know how to Create the credentials that can be used by Jenkins and by jobs running in Jenkins to connect to 3rd party services. You should specify which 3rd party service you will work on. Below is an example of credentials with bitbucket I am now working with Jenkins ver. 1.568. By default, there's Credentials feature. So, if you want to add a credential, just click on Add Credentials . For example, I'd like to add SSH Username with password , so I can use it in checking out code from bitbucket devesh Credentials plugin - provides a centralized way to define credentials that can be

How to increase jenkins build number automatically?

浪子不回头ぞ 提交于 2019-12-03 14:22:45
How to increase jenkins build number automatically or by using shell script?? For now i am doing the same using configure option, and increasing manually. i want to do it automatically. What you are asking for (i.e. keeping the build number same between multiple jobs) is simply impossible in Jenkins. This is done by design (as noted by Jenkins creator himself): "[JENKINS] assumes that the build number is unique and monotonic." . You can change it to a higher value, but changing it to same number will outright break Jenkins and is therefore not possible. Build run number is just that: a run

how can I add git submodule into git repo as normal directory?

六眼飞鱼酱① 提交于 2019-12-03 08:06:51
Let's see what it is Create two git repo sub & test mkdir test sub cd test && git init && touch README && git add README && git commit -m "initialize the git repo" && cd .. cd sub && git init && touch README && git add README && git commit -m "initialize the sub git repo" && cd .. Move the sub repo into test mv sub test cd test git add sub git commit -m "add sub directory" I want to treat them as one git repo and push them remotely, but now the files under sub directory can not be included ? How can I achieve this in simple way like treat sub as normal directory ? Use case for this I try to

How do I get a list of jobs with longest build time in Jenkins

安稳与你 提交于 2019-12-01 17:51:19
问题 I need to generate a weekly report on our Jenkins build cluster. One of the reports is to display a list of jobs that have the longest build time. The solution I can come up with is to parse the "Build history" page on each slave (also master) and for each build of a job, parse the build page and look for "Took x min x sec on slave-xx". This feels quite cumbersome, does anyone know a better solution using Jenkins API or Groovy script console? Thanks 回答1: You can get the build data for your

Jenkins Groovy: What triggered the build

喜欢而已 提交于 2019-11-29 08:02:58
I was thinking of using a Groovy script for my build job in Jenkins because I have some conditions to check for that might need access to Jenkins API. Is it possible to find out who or what triggered the build from a Groovy script? Either an SCM change, another project or user. I have just begun reading a little about Groovy and the Jenkins API. I want to check for the following conditions and build accordingly. Some Pseudocode: def buildTrigger JenkinsAPI.thisBuild.Trigger if (buildTrigger == scm) { execute build_with_automake def new_version = check_git_and_look_up_tag_for_version if (new

How can I create parameterized Jenkins job?

五迷三道 提交于 2019-11-28 01:27:51
问题 I want to use same job in different machine. But I don't want to change the configuration of the job each time. Can I pass the machine name label as parameter and run the job in different machine ? (Not simultaneously). I want to pass parameters while running a job to the script which I have written in th configuration (batch script). Can we do that ? Can I get a return value from a job and use it in next job? 回答1: Yes, you can pass a node label parameter with NodeLabel Parameter Plugin. Yes,