6

I am very new to Jenkins.

There are multiple jobs already configured in Jenkins, As of now we are running all the jobs manually one after the other. I want to make it a single job by pipeline plugin, So that manual effort is reduced.

I had gone through the links, It states we should have JenkinsFile in our repository it basically contains command's to execute the different tasks.

But if i am configuring it in JenkinsFile how can give the existing job names ?

Is it the only way to do a pipeline or is there any other way to achieve this ?

Ex : I have three jobs

  1. build-dev-code
  2. test-dev-code
  3. deploy-stage

I would like to pipeline all the three jobs,

  deploy-stage-ci 

So that it contains all the 3 above mentioned jobs.

Lino
  • 5,084
  • 3
  • 21
  • 39
Jay
  • 429
  • 2
  • 8
  • 23
  • If you use a pipeline you will have a single *job* with multiple *stages*. You can use the same names for those stages as you used for the jobs they replace, if you like. – jonrsharpe Dec 26 '16 at 10:18
  • Could you give any example – Jay Dec 26 '16 at 10:19
  • If you Google "jenkinsfile pipeline" there are plenty out there already! – jonrsharpe Dec 26 '16 at 10:20
  • Is there any other way? If i don't want to include JenkinsFile – Jay Dec 26 '16 at 10:22
  • Given that it's now the standard way of doing things, why don't you want to include a Jenkinsfile? – jonrsharpe Dec 26 '16 at 10:22
  • I want to make use of the jenkins jobs which are already existing... Is it possible to include them in JenkinsFile? – Jay Dec 26 '16 at 10:26
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/131502/discussion-between-jay-and-jonrsharpe). – Jay Dec 26 '16 at 10:28

1 Answers1

13

You don't always need a Jenkinsfile to use Pipeline. In your Pipeline job, choose "Pipeline Script" from the dropdown to get a script editor. Pipeline script editor

To build your three jobs sequentially, in a pipeline, use the following script (using names from your example). It simply wraps each job in a stage and builds it. This will also give you a pretty stage view while it runs your jobs:

stage('Build') {
  build 'build-dev-code'
}
stage('Test') {
  build 'test-dev-code'
}
stage('Deploy') {
  build 'deploy-stage'
}
badgerr
  • 7,802
  • 2
  • 28
  • 43
  • Exactly, the same way i tried and it is working.. One more thing i would like to know is can we have the parameters passed for each job once pipeline is started?? – Jay Jan 06 '17 at 02:51
  • @Jay http://stackoverflow.com/questions/37025175/pipeline-pass-parameters-to-downstream-jobs – badgerr Jan 06 '17 at 09:57