0
0
Jenkinsdevops~20 mins

Credentials for Git access in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Credentials Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Jenkins Git Credentials Types

Which type of Jenkins credential is best suited for accessing a private Git repository using SSH keys?

ASSH Username with private key
BCertificate
CSecret text
DUsername and password
Attempts:
2 left
💡 Hint

Think about what is commonly used for secure Git access over SSH.

💻 Command Output
intermediate
2:00remaining
Jenkins Git Credential Usage Output

What will be the output of the Jenkins pipeline step when using a Git credential with ID 'git-creds' to clone a private repository?

pipeline {
  agent any
  stages {
    stage('Clone') {
      steps {
        git url: 'git@github.com:example/private-repo.git', credentialsId: 'git-creds'
      }
    }
  }
}
AClones the repository successfully without asking for username or password
BFails with authentication error due to missing credentials
CPrompts for username and password interactively
DClones the repository but ignores the credentialsId
Attempts:
2 left
💡 Hint

Jenkins uses the credentialsId to authenticate automatically.

Configuration
advanced
2:00remaining
Configuring Jenkins Credentials for Git HTTPS Access

Which Jenkins credential configuration is correct for accessing a private Git repository over HTTPS that requires a username and personal access token?

ASSH Username with private key
BUsername with password, where password is the personal access token
CSecret file containing the token
DCertificate with private key
Attempts:
2 left
💡 Hint

HTTPS Git access usually requires username and token as password.

Troubleshoot
advanced
2:00remaining
Troubleshooting Jenkins Git Credential Errors

Jenkins fails to clone a private Git repository with the error: 'Authentication failed'. The pipeline uses a credentialsId for SSH access. What is the most likely cause?

AThe Jenkins agent does not have Git installed
BThe repository URL is using HTTPS instead of SSH
CThe credentialsId is not specified in the pipeline
DThe private key in Jenkins credentials is missing or invalid
Attempts:
2 left
💡 Hint

Check the private key validity in Jenkins credentials.

🔀 Workflow
expert
3:00remaining
Securely Managing Git Credentials in Jenkins Pipeline

Which Jenkins pipeline snippet securely uses Git credentials stored in Jenkins to clone a private repository and avoids exposing credentials in logs?

AwithCredentials([usernamePassword(credentialsId: 'git-creds', usernameVariable: 'USER', passwordVariable: 'PASS')]) { sh 'git clone https://$USER:$PASS@github.com/example/private-repo.git' }
Bsh 'git clone https://username:password@github.com/example/private-repo.git'
Cgit url: 'git@github.com:example/private-repo.git', credentialsId: 'git-creds'
Dsh 'git clone git@github.com:example/private-repo.git'
Attempts:
2 left
💡 Hint

Consider Jenkins built-in Git step and credential masking.