0
0
Jenkinsdevops~10 mins

Freestyle job creation in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new freestyle job named 'MyJob'.

Jenkins
job = Jenkins.createJob('[1]')
Drag options to blanks, or click blank then click option'
ATestJob
BMyJob
CBuildProject
DDeployApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different job name than 'MyJob'.
Forgetting to put the job name in quotes.
2fill in blank
medium

Complete the code to add a shell build step that echoes 'Hello World'.

Jenkins
job.addBuildStep(new Shell('[1]'))
Drag options to blanks, or click blank then click option'
Aecho Hello World
Becho Hello
Cprint('Hello World')
Decho 'Hello'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incomplete echo commands.
Using print instead of echo in shell.
3fill in blank
hard

Fix the error in the code to set the job description to 'Sample Job'.

Jenkins
job.setDescription([1])
Drag options to blanks, or click blank then click option'
A'Sample Job'
BSample Job
C"Sample Job"
DSample_Job
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the description string.
Using variable names instead of string literals.
4fill in blank
hard

Fill both blanks to configure the job to trigger on SCM changes and set the SCM URL.

Jenkins
job.setTriggers(new SCMTrigger('[1]'))
job.setScm(new GitSCM('[2]'))
Drag options to blanks, or click blank then click option'
AH/5 * * * *
Bhttps://github.com/example/repo.git
CH/10 * * * *
Dgit@github.com:example/repo.git
Attempts:
3 left
💡 Hint
Common Mistakes
Using SSH URL instead of HTTPS for SCM.
Using wrong cron syntax for trigger.
5fill in blank
hard

Fill all three blanks to create a freestyle job with a description, a shell build step, and a post-build email notification.

Jenkins
job = Jenkins.createJob('[1]')
job.setDescription('[2]')
job.addBuildStep(new Shell('[3]'))
job.addPublisher(new EmailNotifier('team@example.com'))
Drag options to blanks, or click blank then click option'
ADeployApp
BDeployment job for production
Cecho Deployment started
DTestJob
Attempts:
3 left
💡 Hint
Common Mistakes
Using mismatched job names and descriptions.
Forgetting to add the shell build step.