How to know port number in jenkins? - jenkins

I downloaded the Jenkins.war file and ran the command java -jar jenkins.war in my war file directory. It started Jenkins on the default port 8080 but now I want to change the Jenkins default port as I am running tomcat on port 8080. I did not found any Jenkins.xml file in my C:/User/Username/.jenkins folder. How to change the default port for Jenkins in this case?

If you need to run Jenkins on another port, just use the following syntax: java -jar jenkins.war -httpPort=<port-number>
For example, java -jar jenkins.war -httpPort=9090
I would suggest you run Jenkins as a service instead of running it using command line. This will ensure Jenkins keeps running when you restart your system.
Note: Regarding missing jenkins.xml file, i too don't have it in my installation dir. However, if you install Jenkins as a service using the steps provided here, it will then generate the jenkins.xml file. FYI, i am using Jenkins version 2.222.4

Related

Create Jenkins slave from command line

I have a script that create a VM then I need to add the new VM as a slave to existing master,
How can I do that from command line in windows and from the new VM ?
Create a VM (OS = WINDOWS)
Create a Node on jenkins server from command line using jenkins cli:
config.xml | ssh -l fmud -p %JNLP_PORT% %jenkins_IPADDRESS% create-node %TARGET_WIN_NODE_NAME%
Where Config.xml could be gathered from an existing slave with command:
ssh -l fmud -p %JNLP_PORT% %jenkins_IPADDRESS% get-node %TARGET_WIN_NODE_NAME%
Note: JNLP is needed for jenkins-CLI and could be configured in jenkins administrative page.
Also, you will have to change the config file with label and name etc.
Connect the windows slave as service: Download winsw.exe
Rename it to jenkins_slave.exe
Download slave.jar (http://yourserver:port/jnlpJars/agent.jar )
Download and configure jenkins-slave.xml
Download and configure jenkins-slave.exe.config
in cmd: jenkins_slave.exe install
jenkins_slave.exe start
If it is a java slave, that is simple to automate. Like it if you find it helping or ask more specific question otherwise.

How to add jenkins user to docker startup options on a Mac?

I need to add the following to the list of Docker startup arguments on my Mac:
-G jenkins
Does anyone know where on Mac OS X is the Docker configuration file?
I have migrated my jenkins server to Linux, where it was very obvious where the docker config file is to be found.

Where is jenkins.xml in jenkins docker container

We are using jenkins inside docker (version: FROM jenkins:1.651.1).
We have problems with the html publisher plugin which isn't executing javascript by default. The same issue as described here.
We want to change our jenkins.xml (just like they said) to change it's configuration. The problem is the fact we can't find it inside our container. Does it has another name inside the docker container or where can we find it? Thanks
The jenkins docker image does not contain a jenkins.xml. This looks to be a windows specific file.
$ docker run --rm jenkins find / -name 'jenkins.xml' 2>/dev/null
# returns nothing
/usr/local/bin/jenkins.sh is run when a jenkins container is started. This contains the line:
eval "exec java $JAVA_OPTS -jar /usr/share/jenkins/jenkins.war $JENKINS_OPTS \"\$#\""
Therefore try setting the required setting in JENKINS_OPTS:
docker run -e JENKINS_OPTS="hudson.model.DirectoryBrowserSupport.CSP=" jenkins

Update Jenkins which is currently running as a Linux service

How do I update jenkins from a existing jenkins install running as a Linux service without loosing any jobs or config?
First, you need to find where your jenkins.war file is installed:
locate jenkins.war
On my Centos machine, it's here: /usr/share/jenkins/jenkins.war
Stop the Jenkins service:
service jenkins stop
Next, you can backup the existing jenkins.war file:
cd /usr/share/jenkins
mv jenkins.war jenkins-1.586.war
And to finish, please copy the new jenkins.war file in the same location:
cp jenkins.war /usr/share/jenkins/jenkins.war
Restart the Jenkins service:
service jenkins start
It should work and you should retrieve your Jenkins configuration (which is stored in your Jenkins home folder).

How can I add Jenkins slave nodes via the CLI?

As per the title, in Jenkins how can I add new slave nodes to my build cluster using the CLI, or if there is not a CLI option, is there another scriptable approche that can be used?
Basic CLI instruction can be found here.
The following CLI command should get the new node configuration XML as stdin:
java -jar jenkins-cli.jar -s [JENKINS_URL] create-node [NewNodeName]
For example, if you want to copy an existing node, you can use:
java -jar jenkins-cli.jar -s [JENKINS_URL] get-node [NodeToCopyFrom] | java -jar jenkins-cli.jar -s [JENKINS_URL] create-node [NewNodeName]
Many people use the Swarm Plugin to eliminate the need to actually add slaves manually. You would need to script the install of the swarm agent of course, but that should be pretty straight forward.

Resources