Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
1 answers
1909 views
Permissions Issue creating folder on remote host with Jenkins
I'm having an issue with using Jenkins to create a folder on a remote host. The remote host in this case is a stock Ubuntu 20.04 AMI EC2 server with the default `ubuntu` user. I am connecting with the `ubuntu` user to the remote server with the code below: ``` sshagent(credentials : [branchConfig.SS...
I'm having an issue with using Jenkins to create a folder on a remote host. The remote host in this case is a stock Ubuntu 20.04 AMI EC2 server with the default ubuntu user. I am connecting with the ubuntu user to the remote server with the code below:
sshagent(credentials : [branchConfig.SSH_CREDENTIALS_NAME]) {
    sh 'ssh -o StrictHostKeyChecking=no ' + branchConfig.SSH_USER + '@' + branchConfig.DOCKER_HOST + ' "echo \"running whoami\" && whoami && echo \"running groups\" && groups && install --directory --mode 0755 --owner ' + branchConfig.SSH_USER + ' --group ' + branchConfig.SSH_USER + ' ~/importengine"'
}
This outputs the following error: + ssh -o StrictHostKeyChecking=no ubuntu@x.x.x.x echo running whoami && whoami && echo running groups && groups && install --directory --mode 0755 --owner ubuntu --group ubuntu ~/importengine Warning: Permanently added 'x.x.x.x' (ECDSA) to the list of known hosts. running whoami ubuntu running groups ubuntu docker install: cannot change owner and permissions of ���/home/ubuntu/importengine���: Operation not permitted I can see that the folder gets created, but it has the following permissons:
drwxr-xr-x 2 root   root   4.0K Oct 13 11:12 importengine
If I delete the folder and run the following command (when logged in as ubuntu):
install --directory --mode 0755 --owner ubuntu --group ubuntu ~/importengine
...then the folder gets created with the following permissions:
drwxr-xr-x 2 ubuntu ubuntu 4.0K Oct 13 11:24 importengine
### Question **Why is the folder getting created as owned by root in the first place?** After all, I can clearly see that whoami outputs as ubuntu, and not root in the error output so it should be creating the folder as if the ubuntu user.
Programster (2289 rep)
Oct 13, 2021, 11:26 AM • Last activity: Jul 22, 2025, 12:10 AM
1 votes
2 answers
2311 views
How do I run Jenkins with a specific working directory and a specific user account?
I am executing below jenkins.war with below command jenkins -jar jenkins.war But I want to specify to use below path while executing the war `/data/jenkins` and it should run as `jenkins` user . Right now it is getting executed as `root` user and under `/root` directory How can I achieve that ?
I am executing below jenkins.war with below command jenkins -jar jenkins.war But I want to specify to use below path while executing the war /data/jenkins and it should run as jenkins user . Right now it is getting executed as root user and under /root directory How can I achieve that ?
Zama Ques (3376 rep)
Mar 19, 2019, 03:13 AM • Last activity: May 15, 2025, 04:01 AM
0 votes
0 answers
40 views
Can not run script with jenkins user
My host is on alpine Linux and I'm running a jenkins agent on docker. I need the jenkins agent to be able to run a script when it does a build that changes the ownership of a few directories. Every time I run the script as the jenkins user from the container I get "Operation not permitted". I'm able...
My host is on alpine Linux and I'm running a jenkins agent on docker. I need the jenkins agent to be able to run a script when it does a build that changes the ownership of a few directories. Every time I run the script as the jenkins user from the container I get "Operation not permitted". I'm able to run the script fine from the host and fine as root on the container. my dodas config (on host) is: permit persist :wheel permit nopass Local_Admin cmd /srv/scripts/setperm.sh permit nopass :wheel cmd /srv/scripts/setperm.sh I get this when I do id for my host account: uid=1000(Local_Admin) gid=1000(Local_Admin) groups=0(root),10(wheel),18(audio),27(video),28(netdev),1000(Local_Admin),1000(Local_Admin) on the container as the jenkins user i get uid=1000(jenkins) gid=1000(jenkins) groups=10(wheel),1000(jenkins) Any ideas? ***EDIT*** I don't know if it matters but here is the script and permissions #!/bin/sh chgrp -R jenkins /home/jenkins/docker-volumes chmod g+rwx -R /home/jenkins/docker-volumes echo "$USER" id and permissions dockingbay2:~$ cd /srv/scripts dockingbay2:/srv/scripts$ ls -l total 4 -rwsr-xr-x 1 root root 199 May 14 08:29 setperm.sh dockingbay2:/srv/scripts$
andcbii (1 rep)
May 14, 2025, 01:50 PM • Last activity: May 14, 2025, 03:10 PM
0 votes
1 answers
2042 views
Apache mod proxy does use a different charset then proxied server
I'm running jenkins, a java web application, on port 8080 behind an apache2 server using mod_proxy. +---------------+ +----------------+ | apache2 | -----> | jenkins:8080 | +---------------+ +----------------+ When I access jenkins directly e.g. http://myhost:8080/ the result looks normal (All chara...
I'm running jenkins, a java web application, on port 8080 behind an apache2 server using mod_proxy. +---------------+ +----------------+ | apache2 | -----> | jenkins:8080 | +---------------+ +----------------+ When I access jenkins directly e.g. http://myhost:8080/ the result looks normal (All characters are encoded correct). jenkins direct access But when I try it through the apache proxy it looks like this jenkins behind apache2 mod proxy My mod_proxy configuration is SSLEngine on ProxyRequests Off ProxyPreserveHost On AllowEncodedSlashes NoDecode Order deny,allow Allow from all ProxyPass / http://localhost:8080/ nocanon ProxyPassReverse / http://localhost:8080/ RequestHeader set X-Forwarded-Proto "https" RequestHeader set X-Forwarded-Port "443" SetOutputFilter proxy-html SetOutputFilter INFLATE;proxy-html;DEFLATE SetEnv proxy-nokeepalive 1 Header edit Location ^http://myhost/ https://myhost/ My language settings are # echo $LANG en_US.utf8 # echo $LC_ALL en_US.utf8 Does anyone know how to keep the correct charset?
René Link (131 rep)
Sep 14, 2017, 09:25 AM • Last activity: Apr 21, 2025, 07:07 AM
0 votes
2 answers
4523 views
How to run remote server shell script with environment parameters on Jenkins pipeline
I am attempting to run a shell script on a remote server in jenkins scripted pipeline using the `sshScript remote: remote, script:` command. This line of code currently looks like this: sshScript remote: remote, script: './bash.sh' "$env.gitTag" "$env.Version" However, it keeps saying that the param...
I am attempting to run a shell script on a remote server in jenkins scripted pipeline using the sshScript remote: remote, script: command. This line of code currently looks like this: sshScript remote: remote, script: './bash.sh' "$env.gitTag" "$env.Version" However, it keeps saying that the parameters are null there is an error being thrown. I have tried everything and cannot find an answer. I echo the parameters before they are thrown and they contain strings which I expect. 15:56:35 WARNING: Unknown parameter(s) found for class type 'org.jenkinsci.plugins.sshsteps.steps.CommandStep': script [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // node [Pipeline] } [Pipeline] // timestamps [Pipeline] End of Pipeline java.lang.IllegalArgumentException: command is null or empty at org.jenkinsci.plugins.sshsteps.steps.CommandStep$Execution.run(CommandStep.java:69) at org.jenkinsci.plugins.sshsteps.util.SSHStepExecution.lambda$start$0(SSHStepExecution.java:84) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Finished: FAILURE These are the errors being published at the end.
Connor Rasmussen (1 rep)
Jul 26, 2021, 10:05 PM • Last activity: Apr 19, 2025, 04:10 PM
0 votes
1 answers
9594 views
How to put secure password in Jenkins Groovy parameter script
My overall goal is to create a build parameter in Jenkins which is a drop down for only release branches. I have been at this for some time and know there are many ways to do this. Let me run through a few that I have attempted and reason why particular methods will not work for my scenario and why...
My overall goal is to create a build parameter in Jenkins which is a drop down for only release branches. I have been at this for some time and know there are many ways to do this. Let me run through a few that I have attempted and reason why particular methods will not work for my scenario and why the one I am attempting to do is likely the most suited for my application. ## My Current Attempt ## Right now I have Active Choice Parameter. (Others such as Extensible Choice and Extended Choice are also fine), and it has my groovy script in there. Which works exactly how I want it to, except I have to put in plain text my username and password for git.
def getBranches = ("git ls-remote https://:@github.com//.git ").execute()

def branchNameList = getBranches.text.readLines().collect {
  it.split()
}

def releaseBranchList = branchNameList.findAll { it =~ /refs\/heads\/release-candidate-20.*/ }

def humanReadableReleaseBranchList = releaseBranchList.collect {
  it.replaceAll('refs/heads/', '')
}

return humanReadableReleaseBranchList
I know this is not the prettiest, I'm new to groovy. ## What I've tried ## I have of course tried without the : and it fails. I also have tried user secret text or files option in the Build Environment section in order to try and get the environment variables of the github credentials. But after much fighting with this and reading the parameter plugin docs (active choice, extended choice, etc), apparently they do not have access to these environment variables. Those are apparently only accessible once it hits the build step. Unless I am misunderstanding. Which I did try just to make sure, but was unsuccessful. Here is an example of how I tried to get them. - Under Build Environment I selected the "User secret text or file - Gave it a name and selected my github creds - Then in the Groovy Active Parameter script I did something like the following (FYI: I tried several methods, not just this one. If you know of another way please let me know)
def envVars = Jenkins.instance.getGlobalNodeProperties().getEnvVars() 
def GITHUB_USER = envVars['GITHUB_USER']
def GITHUB_PASS = envVars['GITHUB_PASS']
def getBranches = ("git ls-remote https://GITHUB_USER:GITHUB_PASS@github.com//.git ").execute()
Again, I tried many ways. Maybe my syntax was wrong, again I'm very new to Groovy. I did trying something like def getBranches = ("git ls-remote https://" + GITHUB_USER + ":" + GITHUB_PASS + "@github.com//.git").execute() and def getBranches = ("git ls-remote https://${GITHUB_USER}:${GITHUB_PASS}@github.com//.git ").execute() ## Why I chose this method ## I know there are other approaches such as Jenkinsfile's for pipelines. I originally tried that. I did not have much success but I'm happy to try again if I can get past some things that were not working for me such as: - The git ls-remote repo is different than the repo which will container the Jenkinsfile. I could but I really don't want to put the Jenkinsfile in the repo I'm trying to porform the git options on because of the struggle of having to go through a ton of QA steps because it is application code. I can move much faster if I have my Jenkinsfile in a devops repo separate from the application code. - Adding the dynamic parameter did not always seem to update - I also tried using the github api, and for some reason, I got different branch results. Maybe I can attempt this again and figure out why, but I sunk a lot of time into this with no avail. I just wanted to check if there is possibly another solution I havn't found before turning to the Jenkinsfile Pipeline Multirepo checkout approach.
Byron Mansfield (337 rep)
May 17, 2019, 03:43 PM • Last activity: Apr 10, 2025, 04:05 PM
0 votes
0 answers
27 views
Docker return error in Jenkins pipeline
Need some guidance. I am trying to deploy a container in remote server and used groovy script to do this task. I am getting error like below, **[2025-04-02T04:26:43.369Z] + ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'docker run -itd -p 80:80 475798544865.dkr.ecr.ap-south-1.amazonaws.c...
Need some guidance. I am trying to deploy a container in remote server and used groovy script to do this task. I am getting error like below, **[2025-04-02T04:26:43.369Z] + ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'docker run -itd -p 80:80 475798544865.dkr.ecr.ap-south-1.amazonaws.com/my-jenkins-project:"${ECR_Tag}"' [2025-04-02T04:26:43.369Z] docker: invalid reference format** Can someone please check and let me know what wrong is there with this command (marked in *) ? Pipeline stage,
stage ('Docker-deploy-prod') {
		    
			steps {
			    echo "***********************************Starting on remote production server****************************"
				sshagent(['Production']) {
				sh '''
				ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'aws ecr get-login-password --region ap-south-1 | sudo docker login --username AWS --password-stdin 475798544865.dkr.ecr.ap-south-1.amazonaws.com'
				***ssh -o StrictHostKeyChecking=no -l ec2-user 13.127.63.170 'docker run -itd -p 80:80 475798544865.dkr.ecr.ap-south-1.amazonaws.com/my-jenkins-project:"${ECR_Tag}"'***
				'''
			   }
	        }
		}
Piyush Nikhade (11 rep)
Apr 2, 2025, 04:35 AM
2 votes
1 answers
1868 views
Icon next to the build job list not showing up in jenkins
I have a problem with one of my coworkers is not able to see the build icon next to each job. I already tried to make the permissions in `Manage Jenkins -> Configure Settings -> Project-based Matrix Authorization Strategy` to be the same as mine but I can see the icon and my coworker can't, so any h...
I have a problem with one of my coworkers is not able to see the build icon next to each job. I already tried to make the permissions in Manage Jenkins -> Configure Settings -> Project-based Matrix Authorization Strategy to be the same as mine but I can see the icon and my coworker can't, so any help would be appreciated. I'm attaching a picture so everyone knows what I'm talking about. It's the red square box that my co-worker is not able to see. enter image description here
VaTo (3248 rep)
Feb 23, 2017, 06:57 PM • Last activity: Nov 28, 2024, 07:01 AM
10 votes
2 answers
21244 views
Jenkins does not use system's locales
I got a interesting behavior in Jenkins. Jenkins' shell does not use my systems locales. Jenkins runs as user `jenkins` on my system. ###Logged in as `jenkins` via SSH: `locale` displayed: > LANG=en_US.UTF-8 > LANGUAGE=en_US:en > LC_CTYPE="en_US.UTF-8" > etc... `env` shows `LANG` and `LANGUAGE` vari...
I got a interesting behavior in Jenkins.
Jenkins' shell does not use my systems locales. Jenkins runs as user jenkins on my system. ###Logged in as jenkins via SSH: locale displayed:
> LANG=en_US.UTF-8
> LANGUAGE=en_US:en
> LC_CTYPE="en_US.UTF-8"
> etc...
env shows LANG and LANGUAGE variables:
>LANG=en_US.UTF-8
>LANGUAGE=en_US:en
id shows the ID of user:
> uid=1008(jenkins) gid=...
###Entered above commands to a jenkins job shell: locale displayed:
> LANG=
> LANGUAGE=
> LC_CTYPE="POSIX"
> etc...
env does not show LANG and LANGUAGE variables
id shows the ID of user (as expected):
> uid=1008(jenkins) gid=...
###the files: /etc/profile contains:
> export LANG=en_US.UTF-8
> export LANGUAGE=en_US:en
/etc/default/locale contains:
> export LANG=en_US.UTF-8
> export LANGUAGE=en_US:en
startup script /etc/init.d/jenkins should export system's locales:
>\# load environments
>if [ -r /etc/default/locale ]; then
> . /etc/default/locale
> export LANG LANGUAGE
>elif [ -r /etc/environment ]; then
> . /etc/environment
> export LANG LANGUAGE
>fi

Of course I rebooted after modifying the locales ;)

Apache also uses the system's locales
My system is an Ubuntu 14.04 installation.
Did I miss to check something else?

Thank you for reading!
I hope somebody can help :)
whosit (341 rep)
Oct 29, 2014, 09:51 AM • Last activity: Nov 13, 2024, 03:28 PM
1 votes
0 answers
119 views
"ulimit -c unlimited" fails when done "sudo user -c shell-some-script"
I have on a Linux server with SuSE Linux Enterprise 15 SP5 the following situation: I have two unpriv users "sisis" and "jenkins" which are both allowed (based on entries in /etc/security/limits.conf) to run the shell build-in command "ulimit -c unlimited": ``` linux:~ # su - jenkins jenkins@linux:~...
I have on a Linux server with SuSE Linux Enterprise 15 SP5 the following situation: I have two unpriv users "sisis" and "jenkins" which are both allowed (based on entries in /etc/security/limits.conf) to run the shell build-in command "ulimit -c unlimited":
linux:~ # su - jenkins

jenkins@linux:~> id
uid=1003(jenkins) gid=100(users) Gruppen=100(users)
jenkins@linux:~> ulimit -c unlimited ; echo $?
0
exit

linux:~ # su - sisis
sisis@linux:~> id
uid=900118(sisis) gid=900118(sisis) Gruppen=900118(sisis),403(userdevl)
sisis@linux:~> ulimit -c unlimited ; echo $?
0
exit
But, when the user "jenkins" wants to do this in a shell script as user "sisis", this gives an error:
linux:~ # su - jenkins
jenkins@linux:~> cat /tmp/ulimit.sh
#!/bin/sh
export LANG=C
ulimit -c unlimited
jenkins@linux:~> sudo -u sisis -g sisis /tmp/ulimit.sh
/tmp/ulimit.sh: line 3: ulimit: core file size: cannot modify limit: Operation not permitted
The background of this silly question is, that for test automation from another server (a Jenkins Continuous Integration server) jobs are started remotely as
ssh jenkins@linux bash CATserver_start.sh
+ sudo -u sisis /opt/lib/sisis/catserver/etc/S99catserver.testdb start
i.e. the "ulimit -c unlimited" command is issued in the above shellscript /opt/lib/sisis/catserver/etc/S99catserver.testdb which in production is started as user "sisis", but in test automation from the Jenkins CI server via SSH as user "jenkins". Any ideas? Additional information to answer the question in the comment: The real command is as given:
ssh jenkins@linux bash CATserver_start.sh
+ sudo -u sisis /opt/lib/sisis/catserver/etc/S99catserver.testdb start
The exmples given with the script /tmp/ulimit.sh was only to simplfy the problem. The script /opt/lib/sisis/catserver/etc/S99catserver.testdb uses as she-bang #!/bin/bash and after su - sisis the user uses also a bash:
linux:~ # su - sisis
sisis@linux:~> ps
  PID TTY          TIME CMD
21146 pts/1    00:00:00 bash

sisis@linux:~> ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 14448
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 65535
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
Matthias Apitz (31 rep)
Aug 13, 2024, 05:43 AM • Last activity: Aug 13, 2024, 10:55 AM
0 votes
1 answers
1773 views
How to connect to local host 8080 using terminal's hostname in mac?
I have been using docker through direct installation of Community Edition. Can anyone please let me know how to connect to local host after creating a docker container using my machines hostname? Below is a picture of my hostname and the docker command I used for creating a container[![enter image d...
I have been using docker through direct installation of Community Edition. Can anyone please let me know how to connect to local host after creating a docker container using my machines hostname? Below is a picture of my hostname and the docker command I used for creating a containerenter image description here
Yashaswini (21 rep)
Jun 21, 2017, 03:46 PM • Last activity: Aug 3, 2024, 03:04 AM
0 votes
3 answers
1823 views
How to let Jenkins listen to port 80?
With the default configuration, Jenkins is listening to port 8080: $ ss -tulpn | grep 8080 tcp LISTEN 0 50 *:8080 *:* users:(("java",pid=3052,fd=115) However, I want to change that and have Jenkins listen to port 80. When I go into `/etc/sysconfig/jenkins` and change `JENKINS_PORT` to `JENKINS_PORT=...
With the default configuration, Jenkins is listening to port 8080: $ ss -tulpn | grep 8080 tcp LISTEN 0 50 *:8080 *:* users:(("java",pid=3052,fd=115) However, I want to change that and have Jenkins listen to port 80. When I go into /etc/sysconfig/jenkins and change JENKINS_PORT to JENKINS_PORT="80" and restart sudo service jenkins restart, I get: $ ss -tulpn | grep 8080 $ ss -tulpn | grep 80 $ curl localhost:8080 curl: (7) Failed to connect to localhost port 8080 after 0 ms: Connection refused $ curl localhost:80 curl: (7) Failed to connect to localhost port 80 after 0 ms: Connection refused How can I let Jenkins listen to port 80?
Hans (115 rep)
Dec 24, 2021, 02:24 PM • Last activity: Apr 12, 2024, 09:25 AM
1 votes
0 answers
786 views
Jenkins Fontconfig head is null even after installing fontconfig
I am trying to install generic Jenkins with jenkins.war. Getting following error while starting. 2024-03-05 15:23:36.018+0000 [id=1] SEVERE hudson.util.BootFailure#publish: Failed to initialize Jenkins java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration at ja...
I am trying to install generic Jenkins with jenkins.war. Getting following error while starting. 2024-03-05 15:23:36.018+0000 [id=1] SEVERE hudson.util.BootFailure#publish: Failed to initialize Jenkins java.lang.RuntimeException: Fontconfig head is null, check your fonts or fonts configuration at java.desktop/sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1263) I have installed fontconfig rpm -qa | grep fontconfig fontconfig-2.8.0-5.el6.x86_64 fontconfig-devel-2.8.0-5.el6.x86_64 I also tried starting with -Djava.awt.headless=true I am on - openjdk 21 - Jenkins 2.440.1 - Red Hat Enterprise Linux Server release 6.10 (Santiago) - base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Jigar Shah (111 rep)
Mar 5, 2024, 03:36 PM • Last activity: Mar 5, 2024, 04:09 PM
0 votes
1 answers
153 views
Why does this script variable keep showing as "null"?
I have the following script: ```bash def String Service_version = sh "cd ./projects/onehome && pwd && cat package.json | grep version" echo "Service_Version_update: $Service_version" echo "My_Version is : ${Service_version}" ``` The output is: ``` cd ./projects/onehome 13:47:43 + pwd 13:47:43 /home/...
I have the following script:
def String Service_version = sh "cd ./projects/onehome && pwd && cat package.json | grep version"
             echo "Service_Version_update: $Service_version"
             echo "My_Version is : ${Service_version}"
The output is:
cd ./projects/onehome
13:47:43  + pwd
13:47:43  /home/jenkins/agent/workspace/_apps_onehome_feature-AOTF-11540/projects/onehome
13:47:43  + cat package.json
13:47:43  + grep version
13:47:43  "version": "1.0.400",
13:47:43  [Pipeline] echo
13:47:43  Service_Version_update: null
13:47:43  [Pipeline] echo
13:47:43  My_Version is : null
Why is ${Service_version} printed as null?
Jenber Nurye (1 rep)
Feb 28, 2024, 09:19 PM • Last activity: Mar 1, 2024, 12:30 PM
0 votes
1 answers
10143 views
JSON on the command line with jq in Jenkins
I used `jq -r '.version' package.json` command to filter the version from package.json file using the terminal. Can we use `jq` command in Jenkins shell without locally installing it?
I used jq -r '.version' package.json command to filter the version from package.json file using the terminal. Can we use jq command in Jenkins shell without locally installing it?
Janith (191 rep)
Nov 9, 2018, 05:59 AM • Last activity: Feb 13, 2024, 01:16 PM
0 votes
0 answers
911 views
How can I echo/print the environment files of a directory/path in a Jenkinsfile during a build?
In a Jenkins file, I have the following code: #!/usr/bin/env groovy .... def env_prod = 'prod.env' def entrypoint = "${env.WORKSPACE} The above is then combined like this: ${env.WORKSPACE}/$env_prod And it is fed into a python script (through `argparse`); the Python script looks like: def get_packag...
In a Jenkins file, I have the following code: #!/usr/bin/env groovy .... def env_prod = 'prod.env' def entrypoint = "${env.WORKSPACE} The above is then combined like this: ${env.WORKSPACE}/$env_prod And it is fed into a python script (through argparse); the Python script looks like: def get_package_reference_versions(packages, env_path, env_format): with open(env_path) as f: deps = f.read() .... In my Jenkins logs, I see: [2024-01-25T13:39:41.780Z] File "/opt/bmll/miniconda/lib/python3.11/site-packages/something/deployment.py", line 421, in get_package_reference_versions [2024-01-25T13:39:41.780Z] with open(env_path) as f: [2024-01-25T13:39:41.780Z] ^^^^^^^^^^^^^^ [2024-01-25T13:39:41.780Z] FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/jenkins/workspace/pipeline-deployments/js-deployment-cr/prod.env' Now I am trying to figure out what is inside the js-deployment-cr directory. Is there a way to print the environment files inside the js-deployment-cr directory? N.B. I CANNOT MAKE CHANGES IN THE PYTHON SCRIPT, because it sits in a different repository to the bash script. So I need to figure this out in the Jenkins file.
Patrick_Chong (111 rep)
Jan 26, 2024, 03:04 PM • Last activity: Jan 26, 2024, 03:53 PM
0 votes
0 answers
61 views
Why are four Jenkins build nodes suddenly having fatal problems finding things on the PATH?
In our overall organization, we run Jenkins 2.303.1 onprem. We run thousands of builds a day. The project I work on uses one Jenkins master and a set of about ten build nodes. We build a few hundred Maven/Java/Spring applications with similar architectures. In the build process, we have a "tools ima...
In our overall organization, we run Jenkins 2.303.1 onprem. We run thousands of builds a day. The project I work on uses one Jenkins master and a set of about ten build nodes. We build a few hundred Maven/Java/Spring applications with similar architectures. In the build process, we have a "tools image" that contains java and mvn and some other tools. Yesterday, we updated the build process to reference a newer version of the tools image that has some additional tools we need to use. A little later after we made that update, we noticed that there were now four build nodes where builds were all failing in the same way, with this approximate command line and output: + bash -o pipefail -c mvn -U -s ... -Duser.home=/ clean compile test-compile 2>&1 | tee mvn.out The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program. Note that this command is run by a "sh" pipeline step. This error message comes from inside the "mvn" script. This error will occur if it finds that $JAVA_HOME/bin/java doesn't exist. I then added several "sh" calls before this to show the following: * which java * which mvn * ls -lt $JAVA_HOME/bin/java On the "bad" nodes, the result from both of the first two commands was an empty string. That means that neither "java" nor "mvn" are found in the PATH, or they are not executable. On the "good" nodes, they print the expected location of the "java" and "mvn" executable. The output from third command is this: -rwxr-xr-x. 1 root root 12768 Oct 17 21:48 /opt/java/openjdk/bin/java I also added the "env" output before this. It shows that "JAVA_HOME" is equal to "/opt/java/openjdk", and that PATH has the bin directories of both the mvn and java distribution in the PATH. This evidence shows multiple factors that just don't make sense together. The "mvn" script is clearly complaining that $JAVA_HOME/bin/java does not exist, but the sh output clearly shows it does. The "which mvn" output says that "mvn" is not found in the PATH, but the bash command line above is executing just "mvn" without an absolute path, so the only way it could get to it is from the PATH, and it clearly shows that it is finding it, otherwise that error message would not be printed from inside the "mvn" script. I've tried to compare several aspects of the builds running on the "good" nodes with the ones running on the "bad" nodes. For instance, I copied the list of env vars from both and compared them, and there were no significant differences. We tried restarting the bad build nodes. We tried purging the entire local docker cache and restarting docker. Neither of these steps made a difference. I'm looking for any ideas of possible areas to explore to explain this problem. We've had several people staring at this for quite a while now, including one person who maintains the Jenkins build nodes, one person who maintains the tools image, and several others with considerable experience. We are all drawing a blank here.
David M. Karr (1173 rep)
Jan 19, 2024, 09:09 PM • Last activity: Jan 19, 2024, 09:30 PM
0 votes
1 answers
814 views
declare: not found error in Jenkins pipeline
I have a Jenkins pipeline which has a step running a `sh` script. Something like this, but with more commands in between which are not relevant: steps { echo 'Running build with all parameters' sh ''' #!/bin/bash declare -A tests ... etc When I run it on a Jenkins node with CentOS, everything is fin...
I have a Jenkins pipeline which has a step running a sh script. Something like this, but with more commands in between which are not relevant: steps { echo 'Running build with all parameters' sh ''' #!/bin/bash declare -A tests ... etc When I run it on a Jenkins node with CentOS, everything is fine, pipeline runs successfully with all the steps/commands. But when I run the same pipeline on a Jenkins node with Ubuntu, I get this error: + declare -A tests /opt/jenkins-slave/workdir/workspace/Metaweb@tmp/durable-9a389b8a/script.sh: 14: declare: not found Any ideas?
Catalin Nicolae (1 rep)
Nov 1, 2023, 02:54 PM • Last activity: Nov 2, 2023, 04:07 PM
0 votes
3 answers
3395 views
Jenkins sh : wait for wget download to finish
I have a hard time to force wget command to wait until download finish's, problem occurs inside Jenkins `sh '''script place '''`. I have wrote the script in `.sh` file, where it runs without any issues, but after moving it into Jenkins other command in Jenkins executes before the download completes....
I have a hard time to force wget command to wait until download finish's, problem occurs inside Jenkins sh '''script place '''. I have wrote the script in .sh file, where it runs without any issues, but after moving it into Jenkins other command in Jenkins executes before the download completes. script I'm using looks like this sh ''' ssh -i "${keyfile}" -v -o StrictHostKeyChecking=no myuser@myVM << ENDSSH cd /toFolder ls -l echo if [ -f *.zip ] then echo "zip file already exists. Aborting" exit 1 fi wget ${URL} sleep 1 export ZIP_FILENAME=ls *.zip echo run: deployment.sh -j $ZIP_FILENAME echo deployment.sh -j $ZIP_FILENAME ENDSSH ''' for the sake of pasting this code here I have moved ENDSSH on the last line under deployment script to keep it inside the code block. (I know it should be far left of the script) so my problem is that finding the file name which has to be deployed with deployment.sh is executed before download is completed. Tried to use wait command, as well as sleep, which I do not think is a best way to do it, but wait command does not wait at all and sleep command works from time to time. curl behavior is exactly the same. any advices will be much appreciated, as long as I'm not with enough knowledge in Linux scripting.
Re Viki (1 rep)
Jun 24, 2022, 01:22 PM • Last activity: Aug 18, 2023, 07:01 AM
2 votes
4 answers
6828 views
Disowning child from parent process
If `$PID_PARENT` launched `$PID_CHILD`, how can I detach (`disown`?) `$PID_CHILD` from `$PID_PARENT` so that, when I kill `$PID_PARENT`, `$PID_CHILD` keeps running like nothing happened? Concretely, my `$PID_PARENT` is the process running `Jenkins` (or the `Java` process that runs the server that ru...
If $PID_PARENT launched $PID_CHILD, how can I detach (disown?) $PID_CHILD from $PID_PARENT so that, when I kill $PID_PARENT, $PID_CHILD keeps running like nothing happened? Concretely, my $PID_PARENT is the process running Jenkins (or the Java process that runs the server that runs Jenkins) and $PID_CHILD is a _really long_ job that I don't want to have to restart after restarting Jenkins (which is needed for some maintenance). Essentially, I want to stop Jenkins but not stop the long job it started and I know both PIDs. **UPDATE 1:** I found out about disown and tried from a login shell (so not the parent PID shell):
-shell
disown $PID_CHILD
but got
-bash: disown: 13924: no such job
The $PID_CHILD correct and doing
-shell
ps -o ppid= $PID_CHILD
returns $PID_PARENT **UPDATE 2:** As per @Rui's answer , I made a temporary hack job in Jenkins that only runs from the parent shell this time:
-shell
disown 13924
but still got
disown: 13924: no such job
amphibient (12702 rep)
Jun 27, 2018, 03:44 PM • Last activity: Jul 31, 2023, 03:25 PM
Showing page 1 of 20 total questions