Complete the code to specify the Git credentials ID in a Jenkins pipeline.
git url: 'https://github.com/example/repo.git', credentialsId: '[1]'
The credentialsId must match the ID of the stored Jenkins credentials for Git access.
Complete the Jenkins pipeline snippet to checkout a Git repository using stored credentials.
checkout([$class: 'GitSCM', branches: [[name: 'main']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git', credentialsId: '[1]']]])
The credentialsId must be the ID of the Jenkins credentials configured for Git access.
Fix the error in this Jenkins pipeline snippet by filling the correct credentials ID.
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/example/repo.git', credentialsId: '[1]'
}
}
}
}The credentialsId must be the correct ID matching the stored Jenkins credentials to avoid authentication errors.
Fill both blanks to configure Git checkout with branch and credentials in Jenkins pipeline.
checkout([$class: 'GitSCM', branches: [[name: '[1]']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git', credentialsId: '[2]']]])
The branch name should be the target branch (e.g., 'main'), and the credentialsId must match the Jenkins stored credentials.
Fill all three blanks to define a Jenkins pipeline stage that checks out a Git repo with credentials and branch.
stage('Checkout') { steps { checkout([$class: 'GitSCM', branches: [[name: '[1]']], userRemoteConfigs: [[url: '[2]', credentialsId: '[3]']]]) } }
The branch name is 'main', the repository URL is the GitHub repo, and the credentialsId is the Jenkins stored credentials ID.