.net - Git commit and push issue in Jenkins multibranch pipeline -
i'm working on multibranch pipeline in jenkins building .net application , creating ms test results using msbuild on windows server. i've written jenkinsfile same.
now issue is, need commit , push mstest results file same branch on git. i've tried same using 'bat' in jenkinsfile, gives me detached head state
. below jenkinsfile configuration:-
node ('windows') { stage 'checkout' checkout scm stage 'build' bat '"path msbuild.exe" projectfile.proj' bat '"path git.exe" add mstest/output.trx' bat '"path git.exe" commit -am "adding test results"' bat '"path git.exe" push origin develop' }
the call checkout scm
checks out specific commit (latest commit on branch time jenkinsfile
loaded) , results in detached head state.
if want checkout specific branch , later commit changes it, use git directly, in case may that:
bat "<path-to-git.exe> checkout ${env.branch_name}"
obviously, in case else pushes branch after checkout, before jenkins pushes test results, approach might lead unexpected behavior. note, env.branch_name
build variable jenkins multibranch projects gives name of branch pipeline running.
Comments
Post a Comment