Jenkins is not running in CentOs 8 - jenkins

I have installed Jenkins on centos 8. Jenkins status shows, its running, but I cant access through browser. Browser shows 'This site can't be reached'.
But
When I run 'sudo sh Jenkins status' this command, I can access through the browser.
Why this is happening and please help me to start the Jenkins automatically

Related

Error when running any docker command by Jenkins on pipeline

I am running jenkins and docker on Ubuntu server 18.04.2 LTS and when starting
jenkins pipeline to run docker commands, I have this error:
Sorry, home directories outside of /home are not currently supported.
See https://forum.snapcraft.io/t/11209 for details.
script returned exit code 1
Can anyone help me ? Thank you
I had the same issue, I fixed it by just adding "sudo" in front of the docker command

Jenkins CI deploying docker image on Heroku

I have a Jenkins CI and use it to build (mvn) and containerize (docker) my app using Jenkins scripted pipeline. Lastly, I want to deploy my container to Heroku dyno (I have already created an app).
I have followed this documentation https://devcenter.heroku.com/articles/container-registry-and-runtime and have been successfully pushed my docker image to registry.heroku.com/sunset-sailing-4049/web.
The issue is since this announcement https://devcenter.heroku.com/changelog-items/1426 I now need to explicitly execute "heroku container:release web" in order to get my docker container running from registry to app dyno. This is where I am royally stuck. See my below issues:
Heroku is not recognized by Jenkins. (My Jenkins is running on ec2, I have installed heroku toolbelt as ec2-user user. But Jenkins throws error: heroku: command not found). How do I resolve this issue?
How to do "heroku login" from Jenkins, since the login command prompts for browser login. I have added ssh key but I do not know how to use it from the command line, hence Jenkins "shell script"
The only other way I could think of is deploying via heroku pipeline using a dummy git repo onto which Jenkins will upload the source code on a successful build.
Would really appreciate your help solving the above 2 issues.
Thanks in Advance.
You need install heroku as user under which jenkins is running. Or if you installed it globally it may be not in PATH of user under which jenkins is running.
There are multiple options for setting PATH:
Set for specific command.
If your job is pipeline just wrap heroku command in withEnv closure:
withEnv(['PATH+HEROKU=/use/local/bin/']) {
your heroku command here
}
Set path for jenkins slave: go to [Manage Jenkins] -> [Manage Nodes], configure your node and set Environment variable PATH to $PATH:/use/local/bin/. This way all jobs running on slave will get environment variable injected.
For automated cli interactions heroku supports API tokens. You can either put it in ~/.netrc on build machine or supply as environment variable (see here).
(writing here incase someone is facing the same scenario)
ok I took #vladimir's suggestion and did the below:
Heroku command (for jenkins running on ec2):
The below command is needed to push a built docker image to heroku via jenkins/or other ci/cd tool; Because of a recent change (https://devcenter.heroku.com/changelog-items/1426) pushing to heroku registry isn't sufficient any longer. In order to execute the below command you need to install heroku toolbelt.
heroku container:release web
Install snap on amazon linux like below:
follow instruction to enable epel https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/add-repositories.html
Then Modify /etc/yum.repos.d/epel.repo. Under the section marked [epel] , change enabled=0 to enabled=1.
Then do
sudo yum install epel-release
sudo yum install yum-plugin-copr
sudo yum copr enable ngompa/snapcore-el7
sudo yum -y install snapd
sudo systemctl enable --now snapd.socket
Then install heroku toolbelt:
sudo snap install --classic heroku
Deploying to docker image to heroku:
In Jenkins scripted pipeline:
withCredentials([string(credentialsId: 'heroku-api-cred', variable: 'herokuRegistryApiCred')]) {
sh "docker login -u email#example.com -p ${herokuRegistryApiCred} registry.heroku.com"
}
// Tag docker img (in my case it was an image in dockerhub)
sh "docker tag dockerhubusername/pvtreponame:${imageTag} registry.heroku.com/your_app_name/release_type[ie>web]"
sh "docker push registry.heroku.com/your_app_name/web"
sh "/usr/local/bin/heroku container:release web --app=your_app_name"
sh "docker logout registry.heroku.com"
In order to run the app inside docker (in my case it was java) I had to add the below line (otherwise it was crashing because 1. tell app about heroku's port binding. 2. tell web process to run command. The ENTRYPOINT ["java","-jar","my_spring_boot_app-0.0.1-SNAPSHOT.jar"] does not work on heroku.):
CMD ["web", "java $JAVA_OPTS -Dserver.port=$PORT -jar /usr/app/my_spring_boot_app-0.0.1-SNAPSHOT.jar"]

Getting issue with Jenkins running as container, when executing Docker command for build images

Jenkins Docker Problem
Hello Everyone,
I installed DockerTool on Windows7. And running Jenkins in container(http://192.168.99.100:8080), and try build image via freestyle project for a POC. Seems my Jenkins is not able to execute docker command, but getting below error on build : -
"/tmp/jenkins4044405517350577133.sh: 2: /tmp/jenkins4044405517350577133.sh: docker: not found"
I have configured, Docker as Cloud in Jenkins->Configuration, but 'Docker Host URI' as tcp://192.168.99.100:2376 is not being connected, and keep running infinitely.
This value (tcp://192.168.99.100:2376), I get from executing command (docker-machine env) for DOCKER_HOST key.
command output docker-machine env
Please help me out!!!

Calling docker commands from jenkins job as step running outside docker VM

I want to run a docker image create command from a Jenkins job which is running native on my machine with VM running Docker.
I've installed docker build step plugin and in manage Jenkins page command fails when I try to configure docker using url and version, it says:
Test Connection Something went wrong, cannot connect to
http://192.168.99.100:2376, cause: null
I've got this docker url from the docker-machine env command.
In the version field, I tried both REST API version and Docker version, but no success.
Is it possible to call Docker from outside the docker VM and from a Jenkins job? If yes how to configure it in Jenkins?

Updating Jenkins on Centos

I'm trying to update Jenkins on Centos7
When I run service Jenkins status command I can see that Jenkins is active.
When I try to connect to Jenkins using the browser I'm getting this message:
refused to connect to http://*****:8080.
I have followed the following steps but it's not working:
1) Run service Jenkins stop command.
2) Replaced Jenkins.war with the new one.
3) Run service Jenkins start command.
i update it using this command :
yum update jenkins
it's working well
This worked for me on RedHat distribution:
sudo service jenkins stop
yum update jenkins
sudo service jenkins start

Resources