<p>I'm trying to automate deployments using the official ArgoCD docker image (<a href="https://hub.docker.com/r/argoproj/argocd/dockerfile" rel="nofollow noreferrer">https://hub.docker.com/r/argoproj/argocd/dockerfile</a>)</p>

<p>I've created a declarative jenkins pipeline using the kubernetes plugin for the agents and define the pod using yaml, the container definition looks like this:</p>

<pre><code>pipeline {
    agent {
        kubernetes {
            yaml """
kind: Pod
metadata:
  name: agent
spec:
  containers:
  - name: maven
    image: maven:slim
    command:
    - cat
    tty: true
    volumeMounts:
      - name: jenkins-maven-cache
        mountPath: /root/.m2/repository
  - name: argocd
    image: argoproj/argocd:latest
    command:
    - cat
    tty: true
    ...
</code></pre>

<p>I'm trying to run commands inside that container, that step in the pipeline looks like this:</p>

<pre><code>stage('Build') {
    steps {
        container('maven') {
            sh 'echo testing' // this works just fine
        }
    }
}
stage('Deploy') {
    steps {
        container('argocd') {
            sh "echo testing" // this does not work
            // more deploy scripts here, once sh works
        }
    }
}
</code></pre>

<p>So I have two containers, one where the sh script works just fine and another where it doesn't. The sh scripts in the "argocd" container just hangs for 5 minutes and then Jenkins kills it, the exit message is: 
<code>
process apparently never started in /home/jenkins/agent/workspace/job-name@tmp/durable-46cefcae (running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
</code></p>

<p>I can't do echo a simple string in this particular container.</p>

<p>It works fine in other containers like the official for Maven from Docker, I use to build the spring boot application. I can also run commands directly in the argocd container manually from commandline with docker exec, but jenkins just won't in the pipeline for some reason.
What could it be?</p>

<p>I am running the latest version (1.33) of the durable task plugin.</p>

<p><strong>Update:</strong>
Turns out that the image for argo-cd (continuous deployment tool) <em>argoproj/argocd:latest</em> does not include other commands except <code>argocd</code>, so the issue was with the container image I tried to use and not Jenkins itself. My solution was to install the Argo-CD CLI into a custom docker container and use that instead of the official one.</p>

Würden
<p>I've just encountered a similar issue with a custom docker image created by myself.
It turns out, I was using <code>USER nobody</code> in Dockerfile of that image and somehow, this way Jenkins agent pod was unable to run <code>cat</code> command or any other shell command from my pipeline script. Running specific container with root user worked for me.</p>
<p>So in your case I would add securityContext: runAsUser: 0 like below.</p>
<pre><code>...
  - name: argocd
    image: argoproj/argocd:latest
    command:
    - cat
    tty: true
    securityContext:
      runAsUser: 0
...

</code></pre>
<p>Kubernetes reference: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container</a></p>
