node('master') {
stage('Checkout'){
script {
String url = 'https://example.com/repository.git'
//: Branch name containing `/` symbol
String branch = 'feature/branch'
String credentialsId = 'secret-credentials'
//: Checkout original
checkout scm: [
$class: 'GitSCM',
userRemoteConfigs: [
[
url: url,
credentialsId: credentialsId
]
],
extensions: [[$class: 'LocalBranch']],
branches: [
[name: branch]
]
]
//: Change local history
sh('git reset --hard HEAD^')
//: Checkout one more time - local history will be used
checkout scm: [
$class: 'GitSCM',
userRemoteConfigs: [
[
url: url,
credentialsId: credentialsId
]
],
extensions: [[$class: 'LocalBranch']],
branches: [
[name: branch]
]
]
}
}
}