0
0
Jenkinsdevops~10 mins

Credentials for Git access 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 specify the Git credentials ID in a Jenkins pipeline.

Jenkins
git url: 'https://github.com/example/repo.git', credentialsId: '[1]'
Drag options to blanks, or click blank then click option'
Amy-git-credentials
Bgit-username
Crepo-password
Dssh-key
Attempts:
3 left
💡 Hint
Common Mistakes
Using the username or password directly instead of the credentials ID.
Using an incorrect or non-existent credentials ID.
2fill in blank
medium

Complete the Jenkins pipeline snippet to checkout a Git repository using stored credentials.

Jenkins
checkout([$class: 'GitSCM', branches: [[name: 'main']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git', credentialsId: '[1]']]])
Drag options to blanks, or click blank then click option'
Amy-git-credentials
Bssh-key
Cgit-token
Drepo-user
Attempts:
3 left
💡 Hint
Common Mistakes
Using the actual username or token instead of the credentials ID.
Leaving the credentialsId blank or incorrect.
3fill in blank
hard

Fix the error in this Jenkins pipeline snippet by filling the correct credentials ID.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        git url: 'https://github.com/example/repo.git', credentialsId: '[1]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Auser-pass
Bwrong-credentials
Cmy-git-credentials
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using placeholder or incorrect credentials IDs.
Not setting credentialsId at all.
4fill in blank
hard

Fill both blanks to configure Git checkout with branch and credentials in Jenkins pipeline.

Jenkins
checkout([$class: 'GitSCM', branches: [[name: '[1]']], userRemoteConfigs: [[url: 'https://github.com/example/repo.git', credentialsId: '[2]']]])
Drag options to blanks, or click blank then click option'
Amain
Bmy-git-credentials
Cdevelop
Ddefault-creds
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing branch names and credentials IDs.
Using incorrect or default credentials IDs.
5fill in blank
hard

Fill all three blanks to define a Jenkins pipeline stage that checks out a Git repo with credentials and branch.

Jenkins
stage('Checkout') {
  steps {
    checkout([$class: 'GitSCM', branches: [[name: '[1]']], userRemoteConfigs: [[url: '[2]', credentialsId: '[3]']]])
  }
}
Drag options to blanks, or click blank then click option'
Amain
Bhttps://github.com/example/repo.git
Cmy-git-credentials
Ddevelop
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping branch and URL values.
Using incorrect credentialsId.
Leaving any blank empty.