help!Why can’t the git command retrieve the specified branch when placed in dir?
pipeline {
agent any
tools {
nodejs 'nodejs16.20.2'
jdk 'jdk-1.8'
}
parameters {
// 添加参数以选择H5项目的分支
gitParameter(
name: 'H5_BRANCH',
type: 'PT_BRANCH_TAG',
defaultValue: 'master',
branchFilter: 'origin/(.*)',
quickFilterEnabled: true,
description: '选择H5项目的分支',
useRepository: '.*dcim-part-m.git'
)
// 添加参数以选择Android项目的分支
gitParameter(
name: 'ANDROID_BRANCH',
type: 'PT_BRANCH_TAG',
defaultValue: 'master',
branchFilter: 'origin/(.*)',
quickFilterEnabled: true,
description: '选择Android项目的分支',
useRepository: '.*dcim-part-app.git'
)
}
stages {
stage('h5-project') {
steps {
dir('h5-project') {
git branch: "${params.H5_BRANCH}", url: 'https://git.cloudwise.com/dcim/dcim-web/dcim-part-m.git', credentialsId:'ff735acc-4696-435b-a5b1-f25dbd4b1935'
}
}
}
stage('Build H5') {
steps {
dir('h5-project') {
sh 'ls -la'
sh 'npm ci --legacy-peer-deps'
sh 'npm run rsbuild'
}
}
}
stage('android-project') {
steps {
dir('android-project') {
git branch: "${params.ANDROID_BRANCH}", url: 'https://git.cloudwise.com/dcim/dcim-web/dcim-part-app.git', credentialsId:'ff735acc-4696-435b-a5b1-f25dbd4b1935'
}
}
}
stage('Copy H5 to Android') {
steps {
sh 'cp -r h5-project/dist/* android-project/app/src/main/assets/dist/'
}
}
stage('Build Android') {
steps {
dir('android-project') {
sh './gradlew clean assembleDebug'
}
}
}
}
post {
success {
// 归档 Debug APK 文件
archiveArtifacts artifacts: '**/*.apk', fingerprint: true
}
}
}