lanwen I'm also having issue when I'm checking out multiple repos into different directories. I'm running into this error. This is my pipeline code:
stage('in-git-invariant')
{ agent
{ label 'integration' }
steps {
echo "Running on node: ${env.NODE_NAME}"
script {
['in', 'in-frontend', 'in-solr', 'in-oms', 'in-cms', 'in-kit'].each { repoName ->
checkoutStep("*/master", "${repoName}", "${repoName}")
}
withCredentials([string(credentialsId: 'github-internations-jenkins-composer-token', variable: 'GITHUB_COMPOSER_TOKEN')]) {
dir('in-kit')
{ phpComposerInstall() }
sh "php in-kit/bin/in-kit git:invariant ."
}
}
}
post {
always
{ updateGithubCommitStatus() }
}
}
def checkoutStep(branchname, repo, targetdir = "") {
checkout changelog: false, poll: false,
scm: [$class : 'GitSCM',
branches : [[name: "${branchname}"]],
browser : [$class: 'GithubWeb', repoUrl: "http://github.com/InterNations/${repo}"],
doGenerateSubmoduleConfigurations: false,
extensions : [[$class: 'CleanCheckout'],
[$class: 'CleanBeforeCheckout'],
[$class: 'RelativeTargetDirectory', relativeTargetDir: "${targetdir}"],
[$class: 'CloneOption', depth: 0, noTags: true, reference: '', shallow: false],
[$class: 'GitLFSPull']],
submoduleCfg : [],
userRemoteConfigs : [[credentialsId: 'github-internations-jenkins', url: "git@github.com:InterNations/${repo}.git"]]]
}
def updateGithubCommitStatus() {
repoUrl = getRepoURL()
commitSha = getCommitSha()
step([
$class : 'GitHubCommitStatusSetter',
reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitSha],
//reposSource : [$class: 'AnyDefinedRepositorySource'],
//commitShaSource : [$class: 'BuildDataRevisionShaSource'],
contextSource : [$class: 'DefaultCommitContextSource'],
statusResultSource : [
$class : 'ConditionalStatusResultSource',
results: [
[$class: 'BetterThanOrEqualBuildResult', result: 'UNSTABLE', state: 'SUCCESS'],
[$class: 'AnyBuildResult', state: 'FAILURE']
]
],
statusBackrefSource: [$class: 'BuildRefBackrefSource']
])
}
ERROR:
[2020-09-10T08:47:23.271Z] + git config --get remote.origin.url
https://ci.internations.org/blue/organizations/jenkins/in-ci-pipeline-dev/detail/in-ci-pipeline-dev/720/pipeline#step-232-log-2[2020-09-10T08:47:23.271Z] /var/lib/jenkins/workspace/in-ci-pipeline-dev@tmp/durable-a61a120f/script.sh: line 1: .git/remote-url: No such file or directory
You can use variables and not hardcode