I need to create a set of pipelines every month for the new version.
I want to set up a job that will create the Jenkins jobs with Jenkinsfile from the repo
It has to either trigger or run automatically and create a job w.r.t Jenkins file in a folder or workspace.
so that I don't have to access the server whenever I need to run a job
This way I can create the jobs of the new version and patches jobs.
Also, new views if needed. Dashboard I can manage but creating the number of similar jobs with a similar format is waste of time and resources, is there a way to automate it?
Related
I have Jenkins building on every commit and when a new tag is created. Now I need it to build the newest tag every day at 3.
Is there a way to tell the Jenkins cron job to build the newest tag?
I tried adding the cron job to the Jenkins file but it runs on every tag the cron job is in and not just the newest one. Which makes sense but not what I need.
Either create a separate Jenkinsfile or parametrize existing one. Such that this new Jenkinsfile would only build :newest tag.
Then create a separate Job which would run only on cron and point to the new Jenkinsfile (or to an existing one with correctly configured parameters).
That's pretty much all you have to do here.
Each application has its own build job and deploy job. I want to create a dashboard of Jenkins job that contains the builds from different applications and can select the application to deploy instead of going to each deploy job page. Can I create multiple deploys in a single Jenkins job? Something that looks like this:
You'll have to create some Python and Groovy code for this one.
You can:
Divide jobs under different views.
Create a job with Active Parameters in job configuration
Create a groovy script that populates the parameters by fetching jobs view-wise.
Write a Python code that uses HTTP calls using REST API of Jenkins, using selected parameters from Step 3, and execute them.
Basically, you can make one executor job which can help you select job names and execute them using Jenkins APIs.
I want to do a very simple thing - for every new pull request that is being created under my repo, I want to create a new jenkins job with similer configuration (run some batch), that will checkout the branch that is being merged (not the destination branch).
I will also like to delete this job after the pull request is approved, but that's not as important.
How do I do that? Every jenkins plugin that I found creates jobs for all my branches, or for a specified list of branches, instead of just for new ones or just unmerged pull requests
Here is one way you could solve this:
Create a template job containing the logic you want to do for each new branch (i.e. run some batch).
Create a job that is started for every new pull request in your repo. You could probably do this with the Script SCM Plugin using a short groovy script.
Inside this triggered job, clone the job in #1 using the Jobcopy Plugin. Replace any strings (e.g. git url) with whatever is needed to get the job working.
You could write another job that is triggered via the Script SCM Plugin when a branch needs to be deleted. You can remove it using the Groovy Postbuild Plugin.
OK I finally succeseeded, and it was WAY EASIER then I thought. I found a jenkins plugin called "Bitbucket pullrequest builder plugin", and it makes it incrediblly ease to build jobs for pull requests. The only thing is that I couldn't make it work with any OAuth consumer, and had to give it my own credentials. But other then that it works beautifully.
This is very similar with what we did in our team (We have more than 10 development branches and also a lot release branches)
I think the easiest way is as follows:
Plugin should be used:
gerrit trigger plugin
Used to get triggered when there is new commit come in
job dsl plugin
Used to generate the jobs based on the dsl script
build flow plugin
Used to define the execution flow
Create a Jenkins build flow job "EntryPoint" (This job will be triggered if there is a new commit push for review)
Create the a job generator job (This job will invoke the job dsl script to generate the template jobs based on the input parameter, such as branch)
Create a new job to do the cleanup work or as Daniel said, you can do it with groovy post build
Inside the build flow job, a simple flow as follows
//Get current branch from gerrit trigger plugin
def currentBranch = params[GERRIT_BRANCH]
//Invoke job generator job and pass the branch info to it
build ("job_generator",BRANCH:currentBranch )
//Invoke the generated job by job_generator
build("$currentBrnch_Build")
//Remove the generated job
build("CleanUpJob")
I want to create a Jenkins job that starts other Jenkins jobs. That would be quite easy, because Jenkins Template Project Plugin allows us to create a build step of a type "use builders from another project". However, what makes my situation harder is that I have to start Jenkins jobs on other machines. Is there any standard way to do that?
In case you want only to trigger new build of Job You Have plenty of ways to accomplish it
you can use remote access API and Trigger a request to build target job from source Job.
https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
Or you can use https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Remote+Trigger+Plugin
which is handy in handling server details and other stuff. you shoukld ensure ssh keys shared by both servers.
I have a Jenkins task that triggers on any changes made to a gitlab project.
There are a few situations I'd like to be able to set up, however I'm not sure how to best accomplish them. Most of it centers around being able to do the following:
Once the job is complete, I'd like to trigger another job that takes the contents of the first job's workspace (emptying out the initial one).
I'd like for a way to only run certain other jobs when the workspace contains a specific branch (automatically deploy develop branch to a preview environment).
"to trigger another job that takes the contents of the first job's workspace" see Shared workspace plugin:
This plugin allows to share workspaces by Jenkins jobs with the same SCM repos.