i think your issue might be on this line:
"index": "{$index}", "query": "{$query}"}}
i think you might want:
"index": "$index", "query": "$query"}}
you probably should add something like this to the top of the shell script to see what's going on:
echo "$query"
echo "$index"
the full answer is, assuming this declarative pipeline:
pipeline {
agent { label 'docker' }
parameters {
string(name: 'query', defaultValue: 'hot_query_value', description: 'query value')
string(name: 'index', defaultValue: 'hot_index_value', description: 'index value')
}
stages {
stage('build') {
steps {
withEnv(["query=${params.query}" ]) {
sh('./shell_script')
}
}
}
}
}
and this shell script:
#!/bin/sh
echo "in shell script"
echo "query is: $query"
echo "anything query or index-related in env:"
env | egrep -i "query|index"
output in console is:
in shell script
query is: hot_query_value
anything query or index-related in env:
index=hot_index_value
ANOTHER_QUERY_ENV_VAR=hot_query_value
query=hot_query_value
even if you're not using a Jenkinsfile (why do you hate yourself so much? :D), the parameters will already be available as environment variables.