0
0
Jenkinsdevops~10 mins

Source code management setup 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 repository URL in Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        git url: '[1]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ahttps://github.com/example/repo.git
Bgit clone https://github.com/example/repo.git
Crepo.git
Dhttps://github.com/example/repo
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'git clone' command inside the url parameter
Omitting the .git suffix in the URL
Using only the repository name without URL
2fill in blank
medium

Complete the code to checkout a specific branch named 'develop' in Jenkins pipeline.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        git branch: '[1]', url: 'https://github.com/example/repo.git'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Amain
Bmaster
Cdevelop
Dfeature
Attempts:
3 left
💡 Hint
Common Mistakes
Using the default branch name 'main' instead of 'develop'
Using 'master' when the branch is 'develop'
Leaving branch parameter empty
3fill in blank
hard

Fix the error in the Jenkins pipeline code to properly checkout a Git repository with credentials.

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'
Ahttps://github.com/credentials
Bgit-username
Cpassword123
Dmy-git-credentials
Attempts:
3 left
💡 Hint
Common Mistakes
Using username or password directly instead of credentials ID
Using a URL as credentials ID
Leaving credentialsId empty
4fill in blank
hard

Fill both blanks to configure a Jenkins pipeline to checkout a Git repository with a specific branch and credentials.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        git url: 'https://github.com/example/repo.git', branch: '[1]', credentialsId: '[2]'
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Afeature-branch
Bmain
Cmy-credentials-id
Duser-pass
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up branch name and credentials ID
Using username or password instead of credentials ID
Using default branch when a specific branch is needed
5fill in blank
hard

Fill all three blanks to create a Jenkins pipeline snippet that checks out a Git repository, uses a specific branch, and cleans the workspace before checkout.

Jenkins
pipeline {
  agent any
  stages {
    stage('Checkout') {
      steps {
        cleanWs()
        git url: '[1]', branch: '[2]', [3]
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Ahttps://github.com/example/repo.git
Bdevelop
CcredentialsId: 'git-creds'
Dsh 'rm -rf *'
Attempts:
3 left
💡 Hint
Common Mistakes
Using shell command to clean workspace instead of cleanWs()
Omitting credentialsId when authentication is needed
Using incomplete or incorrect repository URL