patternbashMinor
Bash Tokenization Errors on Jenkins JNLP Slave
Viewed 0 times
tokenizationjenkinsslavejnlperrorsbash
Problem
Why might the below bash commands give me an error on a Jenkins JNLP slave in Kubernetes cluster? Each work on a local machine.
Error:
Error:
Environment Details
Error:
Syntax error: redirection unexpected IFS='/' read -r -a branch <<< "${1}"Error:
Syntax error: "(" unexpected (expecting "}"): IFS='/'
branch=($1)Environment Details
- JNLP Slave is using Dockerhub jenkins/jnlp-slave:latest
- Slave being ran with kubernetes plugin
- Jenkins v2.156 on master.
- Command is from a sourced function in another script. (e.g.
. "/script.bash")
Solution
I cannot say this is a the best answer so I do hope someone can provide a better clarification.
It seems the default shell for
This doesn't resolve the the redirection error. Also I would think by updating the default shell in the image with
It seems the default shell for
sh() in Jenkins is Bourne. By updating the sh() with the correct shell this allows the below usage:sh'''#!/bin/bash
IFS='/'
branch=($1)
# Use it.
'''This doesn't resolve the the redirection error. Also I would think by updating the default shell in the image with
chsh -s /bin/bash I wouldn't need to set it but I still do.Code Snippets
sh'''#!/bin/bash
IFS='/'
branch=($1)
# Use it.
'''Context
StackExchange DevOps Q#5990, answer score: 1
Revisions (0)
No revisions yet.