I am using Jenkins Pipeline with Kubernetes Plugin and doing something really simple just to build a container and run the container to execute the tests on it.
While doing it I got a error that shows exit -2 without another information, currently I am just doing a echo.
def containersForUnitTest = [
containerTemplate(name: 'mongotest',
image: 'mongo:3.2.4',
ttyEnabled: true, command: 'mongod --smallfiles',
resourceLimitCpu: '150m',
resourceRequestCpu: '100m',
resourceRequestMemory: '512Mi',
resourceLimitMemory: '512Mi',
alwaysPullImage: false),
containerTemplate(name: 'microservice',
image: "..myimage...",
ttyEnabled: true, command: 'cat',
resourceLimitCpu: '150m',
resourceRequestCpu: '100m',
resourceRequestMemory: '512Mi',
resourceLimitMemory: '512Mi')
]
podTemplate(name: "test", inheritFrom: 'jnlp', label: test", containers: containersForUnitTest) {
node("some") {
stage('Test') {
try {
container('microservice') {
sh """
echo "this is my echo thing"
"""
}
}
catch (Exception e) {
echo "microservice error: ${e}"
throw e
}
}
}
}
If I add the following line to my dockerfile it will run successfully, this seems a awkward behaviour that seems to be related with permissions on the container execution. Don't see any other way to workaround this but it seems undesired.
RUN chown node:node $APP_DIR \
&& apk --no-cache add shadow && usermod -u 10000 node
Any clue? Is there anything that can cause this?