maybe I’ll get lucky and someone will help me)
I’m trying to make a flutter build using Jenkins.
Before running, the flutter command apparently calls shared.bat, which is located in flutter/bin.
REM Check that git exists and get the revision
SET git_exists=false
2>NUL (
PUSHD "%flutter_root%"
FOR /f %%r IN ('git rev-parse HEAD') DO (
SET git_exists=true
SET revision=%%r
)
POPD
)
REM If git didn't execute we don't have git. Exit without /B to avoid retrying.
if %git_exists% == false echo Error: Unable to find git in your PATH. && EXIT 1
I tried to edit this batch file and the git rev-parse HEAD
command runs without errors, I also tried to run this command in papeline jenkins, the result is the same. The problem is that the git_exists variable refuses to be set to true. I’ve already racked my brain why it works this way.
here is my pipeline code:
pipeline {
agent any
environment {
BUILD_DIR = 'E:\WORK\me.develop.projects\grand_train_lite'
}
stages {
stage('build') {
steps {
script {
echo "build..."
bat '''
chcp 1251
SET git_exists=false
2>NUL (
PUSHD "%flutter_root%"
FOR /f %%r IN ('git rev-parse HEAD') DO (
SET git_exists=true
echo 'After2 : %git_exists%'
SET revision=%%r
)
POPD
)
echo 'After1 : %git_exists%'
flutter doctor
'''
dir(BUILD_DIR) {
if (params.BUILD_TYPE == 'debug') {
echo "DEBUG"
//pubversion build
//bat "echo %PATH%"
//bat "pubversion build"
}
}
}
}
}
}
}
output:
C:ProgramDataJenkins.jenkinsworkspacegrandtrain lite>chcp 1251
Текущая кодовая страница: 1251
C:ProgramDataJenkins.jenkinsworkspacegrandtrain lite>SET git_exists=false
C:ProgramDataJenkins.jenkinsworkspacegrandtrain lite>(
PUSHD "C:UserskompoAppDataLocalflutter"
FOR /F %r IN ('git rev-parse HEAD') DO (
SET git_exists=true
echo 'After2 : false'
SET revision=%r
)
POPD
) 2>NUL
C:ProgramDataJenkins.jenkinsworkspacegrandtrain lite>echo 'After1 : false'
'After1 : false'
C:ProgramDataJenkins.jenkinsworkspacegrandtrain lite>flutter doctor
Error: Unable to find git in your PATH.
1