Skip to content

Commit 7a88a8e

Browse files
committed
Fix withEnv inside the script
1 parent 47b4ccc commit 7a88a8e

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

testrail/Jenkinsfile.check-bitrise-ios-release-tags

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ pipeline {
6666
}
6767

6868
stage('Commit and Push Changes') {
69+
environment {
70+
PATH = "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
71+
}
6972
when {
7073
expression {
7174
// Only run if latest_tags.json was modified by the script
72-
def changed = sh(script: '/usr/bin/git diff --quiet testrail/latest_tags.json', returnStatus: true)
75+
def changed = sh(script: 'git diff --quiet testrail/latest_tags.json', returnStatus: true)
7376
if (changed != 0) {
7477
echo "✅ New version detected - latest_tags.json was modified"
7578
return true
@@ -81,7 +84,6 @@ pipeline {
8184
}
8285
steps {
8386
script {
84-
withEnv(["PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"]) {
8587
sh '''
8688
set -e
8789
git config --global user.name 'jenkins-automation'
@@ -111,7 +113,6 @@ pipeline {
111113
'''
112114
}
113115
echo 'Changes committed and pushed successfully'
114-
} // withEnv
115116
}
116117
}
117118
}
@@ -120,8 +121,7 @@ pipeline {
120121
post {
121122
fixed {
122123
// Pipeline recovered: was failing, now passing
123-
script {
124-
withEnv(["PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"]) {
124+
withEnv(["PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"]) {
125125
sh """
126126
curl -X POST ${SLACK_WEBHOOK} \
127127
-H 'Content-Type: application/json' \
@@ -138,15 +138,13 @@ pipeline {
138138
}]
139139
}'
140140
"""
141-
} // withEnv
142141
}
143142
echo '✅ Successfully checked Bitrise tags and updated repository (RECOVERED)'
144143
}
145144

146145
regression {
147146
// Pipeline regressed: was passing, now failing
148-
script {
149-
withEnv(["PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"]) {
147+
withEnv(["PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"]) {
150148
sh """
151149
curl -X POST ${SLACK_WEBHOOK} \
152150
-H 'Content-Type: application/json' \
@@ -163,7 +161,6 @@ pipeline {
163161
}]
164162
}'
165163
"""
166-
} // withEnv
167164
}
168165
echo '❌ Failed to check Bitrise tags (REGRESSION)'
169166
}

0 commit comments

Comments
 (0)