Complete the code to define a multi-branch pipeline in Jenkinsfile.
pipeline {
agent any
stages {
stage('Build') {
steps {
[1] 'echo Building...'
}
}
}
}The sh step runs shell commands in Jenkins pipelines, which is common for build steps.
Complete the code to specify the branch source in a Jenkins multi-branch pipeline configuration.
multibranchPipelineJob('example') { branchSources { git { id('[1]') remote('https://github.com/example/repo.git') } } }
The id is a unique identifier for the branch source, usually a random string or hash.
Fix the error in the Jenkinsfile to correctly define a multi-branch pipeline stage.
pipeline {
agent any
stages {
stage('Test') {
steps {
[1] 'echo Testing...'
}
}
}
}The sh step is used to run shell commands in Jenkins pipelines, which is correct here.
Fill both blanks to complete the Jenkins multi-branch pipeline script that checks out the code and runs a build.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
[1] scm
}
}
stage('Build') {
steps {
[2] 'make build'
}
}
}
}checkout scm checks out the source code. sh runs the build command in shell.
Fill all three blanks to create a Jenkins multi-branch pipeline that triggers on branch changes, checks out code, and runs tests.
multibranchPipelineJob('project') { triggers { [1] { interval('1d') } } branchSources { git { id('abc123') remote('https://github.com/example/project.git') } } factory { workflowBranchProjectFactory { scriptPath('[2]') } } } pipeline { agent any stages { stage('Test') { steps { [3] 'pytest' } } } }
periodicFolderTrigger triggers the job periodically. Jenkinsfile is the default pipeline script file. sh runs shell commands like tests.