gitlab-runner: ERROR: Job failed: prepare environment: exit status 1. when starting sh in windows - shell

On a Windows Server 2012 machine, I've installed gitlab-runner with "shell" executor and a "sh" shell. The following are lines in the config.toml file:
...
executor = "shell"
shell = "sh"
...
I start a CI build and it returns the following error:
...
Preparing environment
Unknown option "-l"
Usage: sh [-XT] [-c cmd] [-o option] [-abCefhGHikLmnprstuvwx] arg ...
ERROR: Job failed: prepare environment: exit status 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

Related

kubectl exec: $PATH: unknown command terminated with exit code 126

Trying to exec into a container with the following command
kubectl exec -it my-pod my-container1 -- bash
Gives error:
OCI runtime exec failed: exec failed: container_linux.go:367: starting container process caused: exec: "my-container1": executable file not found in $PATH: unknown
command terminated with exit code 126
The pod my-pod has two containers. And my-container1 has alipne image with bash installed.
Trying to get shell into the container, it is not able to find bash.
Kubectl client version: v1.17.0
Adding -c before the container name worked.
kubectl exec -it my-pod -c my-container1 -- bash

Run a shell script using kubectl exec - OCI runtime exec failed: exec failed: container_linux.go:346

I am trying a run a shell script via kubectl exec.
Eg- kubectl exec -n abc podxyz -- /root/test/./generate.sh
The script runs in the podxyz container but returns the below error, breaking the rest of the flow.
"command terminated with exit code 126"]
"OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused \"no such file or directory\": unknown"]}
I have tried to use -- /bin/sh and bash after the -- , but that did not help.
Note - the above command is executed as part of another script.

Kubectl: get a shell to a running container under Windows

I'm trying to log into running container using Kubectl, according to instructions in https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/, but I'm failing miserably:
kubectl exec -it mycontainer -- /bin/bash
Unable to use a TTY - input is not a terminal or the right kind of
file rpc error: code = 2 desc = oci runtime error: exec failed:
container_linux.go:247: starting container process caused "exec:
\"D:/Applications/Git/usr/bin/bash\": stat
D:/Applications/Git/usr/bin/bash: no such file or directory"
command terminated with exit code 126
It looks like kubectl tries to exec bash on my machine, which is totally not what I want to achieve.
I can exec commands without spaces:
$ kubectl exec mycontainer 'ls'
lib
start.sh
But with not:
$ kubectl exec mycontainer 'ls .'
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"ls .\": executable file not found in $PATH"
command terminated with exit code 126
What I'm doing wrong?
I've tried both in mingw git shell , as with plain windows console.
Seems it might be related to this github issue.
One of the workarounds might be to use winpty as specified here.
winpty kubectl.exe exec -it pod-name -- sh
You can also try /bin/sh instead of /bin/bash it worked for me, but I do not have a Windows machine to check it in the same environment as you.
Below command worked for me to launch windows command prompt
kubectl exec -it mycontainer -- cmd.exe

Executing a linux command through gradle returns exit status 127

I have this gradle task that runs the following on a machine using remote ssh connection:
println execute(['nohup /opt/ESSyncBatch/runessync.sh &>/dev/null &'])
And here's the content of runessync.sh
#!/bin/sh
cd $(dirname $0)
echo $(pwd)
java -Dspring.batch.job.names=CADB0200 -jar cics-batch.jar
If i run the nohup command on my own ssh connection manually (im using putty), it does the expected but when I run the task on gradle, it fails with the following error:
Command returned exit status 127: 'nohup /opt/ESSyncBatch/runessync.sh &>/dev/
null &'
Any insights?

Jenkins unable to run Python file in Docker - file not found

Added a Jenkins project with a job. Added a file called test.sh with a simple code:
#!/bin/bash
docker run --rm -v $(pwd):/app image_name src/test.py
Jenkins supposed to run test.sh, create a docker container, run src/test.py and remove container:
builders:
- shell: |
./test.sh
However getting an error
./test.sh
python: can't open file 'src/test.py': [Errno 2] No such file or directory
Build step 'Execute shell' marked build as failure
$ ssh-agent -k
unset SSH_AUTH_SOCK;
unset SSH_AGENT_PID;
echo Agent pid 1781 killed;
However `src and src/test.py do exist (checked it).
So what causes the error?

Resources