How to schedule jenkins build from github, without jenkins configure? - jenkins

I am running functional automation test with github and jenkins. I used to schedule jenkins job with 'Build with parameter' option. So with this option, I can run the jenkins pipeline at specific time with cron pattern.
But I want to schedule the job without jenkins UI, from github repository. How can I do it?
Please please help me!
In my github repo, I have jenkinsfile and YAML file.
Can I schedule it from there? Is there any way?
Or will I need to create any new file to schedule/trigger/run the jenkins pipeline at specific time?

Related

Webhook trigger for jenkins remotefile multibranch pipeline job

I have a multibranch configuration job, which I have created for using the remote jenkins file plugin, I have git repo in which I have the "jenkinsfile" named as customjenkins Now I am trying to configure the job in such a way that when ever a change is done to the "jenkinfile" the build should trigger, but in my case the top build is only triggered but the job with repo inside doesnt trigger and only can be done manually, please see the picture below for better understanding. Can anyone tell me what am I missing here

Ephemeral Jenkins Pipeline Jobs from Github and Jenkinsfile

I have automated Jenkins master and slaves deployment and redeployment successfully.
I know how to manually create pipeline jobs and add github repos to use their Jenkinsfiles for the steps.
my issue is how can I automate the pipeline jobs addition to jenkins after its been destroyed and redeployed without having to manually create the pipeline jobs and point to Jenkinsfile each time.
I have seen this done before in a container environment with chef and docker when redeployed or updated it re-adds all the pipelines automatically again.
I want to not use the UI at all only to confirm job status progress and verify settings.
I would recommend looking at the JobDSL Plugin to create jobs, using a seed job to create them on initial Jenkins startup. The Jenkins Configuration-as-Code plugin can be used to setup any other configuration outside the jobs.

Jenkins Multibranch Job configuration as a pipeline Job

I have mutibranch job in jenkins. Is there any way i can do the multibranch job configurations in a Jenkinsfile? like branchsource , behaviours etc in multibranch job i want to store as a code
Short answer is NO.
But if you still want it, you can store job xml configuration in Git, and then update job through Jenkins API using a local script or even another Jenkins job. Don't recommend though.

How to trigger jenkins job that execute automation test scripts when code is pushed in development server?

I am new to Jenkins. I have development code repository at bitbucket and another test script code repository at bitbucket. Now I have setup a Jenkins job by linking test code repository. Is there any way to trigger a build when code is pushed in develop repo?
I tried many times by pushing change in develop repo, but it does not triggers the jenkins job.
You can configure the Jenkins trigger as an SCM poll.
You will have to enter a cron expression for the polling time period, like:
*/5 * * * *
This means polling from 5 to 5 minutes. If any change is detected, then the build is triggered.
You can add the BitBucket Plugin to your Jenkins instance. It will allow you to configure a webhook in BitBucket that will then trigger any Jenkins job listening for that webhook. The plugin's page has a detailed breakdown, but the basics are;
In your repo in BitBucket, create a new Webhook using your Jenkins' url. I believe the url is generally http://[your jenkins url]/bitbucket-hook/
Make the trigger a repo push.
In your Jenkins job, check the box "Build when a change is pushed to BitBucket" under the Build Triggers section.
Now any time you commit to the repo you created the Webhook on, that Jenkins job will be run.
You can also limit what branches trigger commits by parameterizing your Jenkins build to ignore certain branches / keywords / etc if that's something you need for your specific project.
You can use webhooks to trigger build automatically. There are few options how to use it. See the following articles: this, this and this.

Is there a way to turn Jenkins job into a Jenkins DSL script automatically?

I use Job DSL Plugin to generate my Jenkins builds. But sometimes I make small changes to the build in Jenkins and I want to port those changes back to my DSL script automatically. Is there any way to achieve this?
Currently there is no way to generate a Job DSL script for an existing job. This has been reported in the Jenkins issue tracker as JENKINS-16360 some time ago and someone even offered a bounty, but AFAIK no one is working on the issue.

Resources