I'm seeing this same issue as well: "ERROR: script returned exit code -2".
I've looked for more info in the pod logs as Carlos suggested but wasn't
able to find anything helpful.
If I remove the container element and nest sh under node it works. Do I
need to make sure the jenkins user (10000) is available in all the
containers for the pod? I have been pretty stuck here so appreciate any
help.
def label = "buildpod.${env.JOB_NAME}.${env.BUILD_NUMBER}".replace('-', '_'
).replace('/', '_')
podTemplate(label: label, cloud: 'kubernetes', containers: [
containerTemplate(
name: 'jnlp',
image: <internal_registry>/'jenkinsci/jnlp-slave:3.10-1-alpine',
args: '${computer.jnlpmac} ${computer.name}',
ttyEnabled: true),
containerTemplate(
name: 'maven',
image: '<internal_registry>/maven:3.5.0-jdk-8-alpine',
ttyEnabled: true, command: 'cat',
resourceRequestCpu: '100m',
resourceLimitMemory: '1200Mi')
]) {
node(label) {
container('maven') {
sh 'date'
}
}
}
On Thursday, August 24, 2017 at 9:43:19 AM UTC-7, Carlos Sanchez wrote:
>
> I've seen it reported before.
> Check your pod logs, events and exit codes
>
> On Thu, Aug 24, 2017 at 6:35 PM, Pedro Januário <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>>
>> 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.
>>
>> *Example (just part of it):*
>>
>> 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 \
>> && echo http://dl-cdn.alpinelinux.org/alpine/edge/community/ >>
>> /etc/apk/repositories \
>> && apk --no-cache add shadow && usermod -u 10000 node
>>
>> Any clue? Is there anything that can cause this?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/jenkinsci-users/b921176c-33ca-48c2-a06e-a673aa6f6e72%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/1aba8dbe-40ee-4a31-a8ba-5dddd1fbf135%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.