I'm stuck with this problem and I have no idea to solve it.
I have written a Shell script which will invoke my job using Jenkins CLI by passing my private key.Jenkins version is 2.121.1
java -jar jenkins-cli.jar -s http://localhost:8080 -i ~/.ssh/id_rsa build RTT/RTT-CI-Tools/RTT-CI-Tools-Distribute -s -p SLAVE_REGEX=testserver
Getting Error message as :
ERROR: anonymous is missing the Overall/Read permission
The same script works in another Jenkins (2.7.4). How to fix this issue.
You can also use auth param but you should to type your password in console
java -jar jenkins-cli.jar -s http://localhost:8080/ -auth myLoggin:myPassword list-jobs
Please check for below points
1) USER exist on jenkins server as same on linux machine.
2) SSH Public key shared on Jenkins server is correct.(manage jenkins --> manage user --> click on ${USER} --> click on configure --> then check ssh public key is correct).
3) CMD i used(working) --> java -jar jenkins-cli.jar -ssh -user ${USER} -i ~/.ssh/id_rsa -s http://localhost:8080/jenkins/ build ${JOB_NAME}
please check if you are executing cmd from same user.
4) SSH port should be enable on Jenkins (go to manage Jenkins--> configure Global security --> SSH Server... set SSHD Port Fixed eg 38844)
This issue cropped up for me, too, recently (using the cli to automate installing jenkins). I was able to work around it by setting the denyAnonymousReadAccess flag to false in jenkins' config.xml file, and restarting jenkins:
<authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy">
<denyAnonymousReadAccess>false</denyAnonymousReadAccess>
</authorizationStrategy>
Related
So I was trying to deploy a simple CD pipeline using docker by ssh’ing into my AWS Linux EC2 instance in the WSL2 terminal. The job is failing every time returning the following error:
Started by user Navdeep Singh Running as SYSTEM Building on the
built-in node in workspace /var/lib/jenkins/workspace/todo-dev
[todo-dev] $ /bin/sh -xe /tmp/jenkins6737039323529850559.sh + cd
/home/ubuntu/project/django-todo /tmp/jenkins6737039323529850559.sh:
2: cd: can’t cd to /home/ubuntu/project/django-todo Build step
‘Execute shell’ marked build as failure Finished: FAILURE
DockerFile contents:
FROM python:3 RUN pip install django==3.2
COPY . .
RUN python manage.py migrate
CMD [“python”,“manage.py”,“runserver”,“0.0.0.0:8000”]
Everything goes fine. This error cd: can’t cd to /home/ubuntu/project/django-todo Build step ‘Execute shell’ marked build as failure Finished: FAILURE is not an actual.
Your agent Node is not online.
To fix the problem, find commands on your jenkins web page after an agent setup. You need to run those commands from your terminal. See the screenshot for more details.
Make sure that your jenkins public IP and node agent public IP are the same. If an error occurs, you need to run some commands on the terminal. This is not a real error.
this issue follow this step which i give you
For Agent--->
change your ip here(44.203.138.174:8080) to your EC2 ip
1.curl -sO http://44.203.138.174:8080/jnlpJars/agent.jar
2.java -jar agent.jar -jnlpUrl http://44.203.138.174:8080/manage/computer/todo%2Dagent/jenkins-agent.jnlp -secret beb62de0f81bfd06e4cd81d1b896d85d38f82b87b21ef8baef3389e651c9f72c -workDir "/home/ubuntu"
For JOb --->
sudo vi /etc/sudoers
then add this command below root access in sudoers file
jenkins ALL=(ALL) NOPASSWD: ALL
3.then goto the ubuntu directory using cd .. then run this codes
grep ^ubuntu /etc/group
id jenkins
sudo adduser jenkins ubuntu
grep ^ubuntu /etc/group
4.restart the jenkins relogin
sudo systemctl stop jenkins
then you good to go
I am new in jenkins and docker.I am trying to import jenkins new job from xml file.Current jenkins is running inside docker.(jenkinsci/blueocean).
Here is my command:
java -jar .\jenkins-cli.jar -s http://localhost:8080/ create-job jobname .\myjob.xml
Here is error:
anonymous is missing the Overall/Read permission
What I have done:
I already check this one
Anonymous is missing the Overall/Read permission
So I test with this cmd:
java -jar .\jenkins-cli.jar -s http://localhost:8080/ -auth username:password who-am-i
It return
Authenticated as : username
Authorities: authenticated
Then I also try like that :
java -jar .\jenkins-cli.jar -s http://localhost:8080 create-job jobname .\myjob.xml -auth username:password
its also happen error.
Pls help.
I will prefer job import at build time, Here is the working example that you can try.
FROM jenkinsci/blueocean
COPY config.xml /usr/share/jenkins/ref/jobs/job_name/config.xml
You can try working below command to run demo job import
git clone https://github.com/Adiii717/docker-jenkins-job-import.git
cd docker-jenkins-job-import;
docker-compose build
docker-compose up
I want to trigger a build in Jenkins B by running build in Jenkins A, I know that I can use a Curl command from Jenkins A but actually I couldn't figure it how and where to write the command, inside the pipeline or as power-shell script?
Here is described how it works.
You need to download the jenkins-cli.jar from the jenkins server you want to trigger a job on.
wget http://YOUR_JENKINS_HOSTNAME/jnlpJars/jenkins-cli.jar
You have to verify that you can authenticate to the jenkins server.
ssh-keygen -t rsa && cat ~/.ssh/id_rsa.pub
Copy the public key to http://YOUR_JENKINS_HOSTNAME/user/YOUR_USERNAME/configure. On the same page you can generate a API Token. You will need it for the remote call. You can save it as file with the following command:
echo 'YOUR_USERNAME:YOUR_API_TOKEN' > jenkins_secret
Now you can call the remote jenkins server and trigger builds
java -jar ./jenkins-cli.jar -s http://YOUR_JENKINS_HOSTNAME list-jobs
To integrate it to your pipeline just add a sh step and take the last line (the jenkins-cli.jar call) and add it to your pipeline.
Getting below error
Error: you must authenticate to access this jenkins" when trying to run "Java -jar jenkins-cls.jar -s http://localhost:8080 /help
Steps performed as below,
1. Copied jenkins-cls.jar to the local drive.
2. Opened command prompt and navigate to path where jenkins-cls.jar is saved.
3. Type "Java -jar jenkins-cls.jar -s http://localhost:8080 /help" and press enter.
It should ask for pass-code but instead, it displayed message "Error: you must authenticate to access this jenkins".
Any help to resolve this query is highly appreciated.
Go to Manage Jenkins -> Configure Global Security ->
Enable Security Checked
Authorization -> Logged-in Users can do anything -> Checked allow anonymous
read access
Restart Jenkins and try running
java -jar jenkins-cls.jar -s http://localhost:8080 help --username user --password pwd
or
java -jar jenkins-cls.jar -s http://localhost:8080 login -auth username:(password/token).
You have to pass your username and password while executing the command like as below:
java -jar jenkins-cls.jar -s http://localhost:8080 /help --username <userName> --password <password>
The file name is now changed from jenkins-cls.jar to jenkins-cli.jar.
Make sure the user is registered in jenkins front-end and Enable Security is checked for the user.
java -jar jenkins-cli.jar -s http://localhost:8080 -auth username:password
Go into Configure global security section, search for Allow anonymous read access, check it as true, apply and save.
Or you can just choose Anyone can do anything instead of Logged-in users can do anything
Test your command now, it should be work
I am trying to build a job using jenkins-cli.jar, but I cannot figure out how to tell Jenkins the job is in a subdirectory.
$ java -jar jenkins-cli.jar -s https://myserver/ list-jobs util --username Jerry --password swordfish
TheJobIWant
AnotherJob
SomeOtherJob
So the job is clearly there, inside that folder. But when I try to run it, I get:
$ java -jar jenkins-cli.jar -s https://myserver/ build util/TheJobIWant -s --username Jerry --password swordfish
No such job 'util/TheJobIWant'
How am I supposed to call this job from the CLI?
When you were saying 'subdirectory', do you mean 'subview' ?
I've created a job named 'job1' under the netsted view-->subview folder.
When I tried to trigger a build from jenkins command line, I was using:
java -jar jenkins-cli.jar -s http://localhost:8080/ build job1 --username admin --password admin
And as you can see, 'job1' has successfully been triggered.
Hope this helps!
May want to check out https://issues.jenkins-ci.org/browse/JENKINS-11024. There is a workaround by allowing anonymous users read-access to the jobs, but that's not always suitable for every installation.
Use -i option instead of --username --password. Or curl as mentioned in https://issues.jenkins-ci.org/browse/JENKINS-12543