I am struggling with this issue inside my declarative pipeline. I am trying to use python's docker image as my agent and run some scripts and I am receiving warning:
Warning: JENKINS-41339 probably bogus PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/platform-tools; perhaps you meant to use ‘PATH+EXTRA=/something/bin’
I do not have access to Jenkins server global variables configuration. I am using one of the Debian slaves.
I have read other issues about this problem stackoverflow/43987005 and stackoverflow/44378221. Also discussion on Jenkins forum and Jenkins official documentation.
This is code I am executing:
// https://www.jenkins.io/doc/book/pipeline/syntax/
pipeline {
environment {
PATH = "/bin/sh:$PATH"
}
agent {
docker {
image "python:3.9"
}
}
stages {
stage('Test') {
steps {
withEnv(["PATH+EXTRA=$PATH"]) {
sh "PATH is: $PATH"
}
}
post {
cleanup {
cleanWs()
}
}
}
stage('Build') {
steps {
echo "'Let's build"
}
}
stage('Deploy') {
steps {
echo "'Let's deploy"
}
}
}
}
Problem appeared after I wanted to implement docker image as agent and by changing environment section inside my pipeline still haven't fixed my problem. I was trying also these alternatives:
PATH = "/usr/local/bin:$PATH"
PATH = "/usr/local/bin:${env.PATH}"
I also went to Configure
, section Prepare an environment for the run
and filled up Properties Content
input but I still didn't receive $PATH content into my job. I am still receiving global value of $PATH. I also unchecked the Keep Jenkins Environment Variables
checkbox.
The server I am using has Environment Injector Plugin plugin installed.