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.

7
  • 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. Commented Dec 26, 2016 at 10:18
  • Could you give any example Commented Dec 26, 2016 at 10:19
  • If you Google "jenkinsfile pipeline" there are plenty out there already! Commented Dec 26, 2016 at 10:20
  • Is there any other way? If i don't want to include JenkinsFile Commented Dec 26, 2016 at 10:22
  • Given that it's now the standard way of doing things, why don't you want to include a Jenkinsfile? Commented Dec 26, 2016 at 10:22

1 Answer 1

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' } 
Sign up to request clarification or add additional context in comments.

2 Comments

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??

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.