Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot run program "mvn" on containerized agent #224

Open
laukerta opened this issue Sep 30, 2022 · 0 comments
Open

Cannot run program "mvn" on containerized agent #224

laukerta opened this issue Sep 30, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@laukerta
Copy link

Jenkins and plugins versions report

Environment
Paste the output here

What Operating System are you using (both controller, and any agents involved in the problem)?

Linux + Linux-Containers

Reproduction steps

We have pipeline which is configured like this:

pipeline {

  agent {
    // this fluent api is defined by one of our libraries
    // we request an agent which is capable of executing steps within specific containers (see container block below)
    kubernetes(agents().maven('maven').version('3.8-openjdk-17-slim').startContainers())
  }

  stages {
    stage('Release Next Version') {
      steps {
        // 'mvn' command is not defined outside of container block or globally
        // within 'maven' container the environment variables MAVEN_HOME, JAVA_HOME and PATH are set accordingly
        container('maven') {
          script {
            releaseVersion = nextVersion()
            currentBuild.description = releaseVersion
          }
        }
      }
    }
  }
}

Expected Results

We expect that the next version is correctly derived based on the commit history and the conventional commits rules.

Actual Results

We receive an java.io.IOException with the following stack trace:

java.io.IOException: error=2, No such file or directory
  	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
  	at java.base/java.lang.ProcessImpl.<init>(Unknown Source)
  	at java.base/java.lang.ProcessImpl.start(Unknown Source)
  	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
  	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
  	at io.jenkins.plugins.conventionalcommits.process.DefaultProcessHelper.runProcessBuilder(DefaultProcessHelper.java:18)
  	at io.jenkins.plugins.conventionalcommits.utils.MavenProjectType.getCurrentVersion(MavenProjectType.java:31)
  	at io.jenkins.plugins.conventionalcommits.utils.CurrentVersion.getCurrentVersion(CurrentVersion.java:68)
  	at io.jenkins.plugins.conventionalcommits.NextVersionStep$Execution.run(NextVersionStep.java:212)
  	at io.jenkins.plugins.conventionalcommits.NextVersionStep$Execution.run(NextVersionStep.java:133)
  	at org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution.start(SynchronousStepExecution.java:37)
  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
  	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
  	at jdk.internal.reflect.GeneratedMethodAccessor19376.invoke(Unknown Source)
  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
  	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
  	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
  	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
  	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
  	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
  	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
  	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
  	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
  	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
  	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
  	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
  Caused: java.io.IOException: Cannot run program "mvn" (in directory "/home/jenkins/agent/workspace/parsys-gdpr-delete/Release"): error=2, No such file or directory
  	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
  	at java.base/java.lang.ProcessBuilder.start(Unknown Source)
  	at io.jenkins.plugins.conventionalcommits.process.DefaultProcessHelper.runProcessBuilder(DefaultProcessHelper.java:18)
  	at io.jenkins.plugins.conventionalcommits.utils.MavenProjectType.getCurrentVersion(MavenProjectType.java:31)
  	at io.jenkins.plugins.conventionalcommits.utils.CurrentVersion.getCurrentVersion(CurrentVersion.java:68)
  	at io.jenkins.plugins.conventionalcommits.NextVersionStep$Execution.run(NextVersionStep.java:212)
  	at io.jenkins.plugins.conventionalcommits.NextVersionStep$Execution.run(NextVersionStep.java:133)
  	at org.jenkinsci.plugins.workflow.steps.SynchronousStepExecution.start(SynchronousStepExecution.java:37)
  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:322)
  	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:196)
  	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:124)
  	at jdk.internal.reflect.GeneratedMethodAccessor19376.invoke(Unknown Source)
  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:98)
  	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
  	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225)
  	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1034)
  	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:41)
  	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
  	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
  	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
  	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
  	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
  	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:161)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:165)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
  	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:135)
  	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
  	at WorkflowScript.run(WorkflowScript:26)
  	at ___cps.transform___(Native Method)
  	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:86)
  	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:113)
  	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixName(FunctionCallBlock.java:78)
  	at jdk.internal.reflect.GeneratedMethodAccessor350.invoke(Unknown Source)
  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
  	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
  	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
  	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
  	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
  	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
  	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136)
  	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275)
  	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
  	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
  	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
  	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:187)
  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:420)
  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:95)
  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330)
  	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294)
  	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
  	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
  	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
  	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
  	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
  	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
  	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
  	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  	at java.base/java.lang.Thread.run(Unknown Source)

Anything else?

No response

@laukerta laukerta added the bug Something isn't working label Sep 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant