Using the jenkins CLI (on fedora 23) - jenkins

I have a jenkins instance running. To create this instance on a Fedora 23 machine, I installed jenkins (via dnf) and started it (via systemd). It is running and I can see it in my browser at http://localhost:8080.
I have been trying to follow the directions in https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI.
I download http://localhost:8080/jnlpJars/jenkins-cli.jar to my computer.
Then I try to run the program java -jar jenkins-cli.jar http://127.0.0.1 -s help and I get no main manifest attribute, in jenkins-cli.jar
When I check jenkins-cli.jar, sure enough there is no Main-Class entry in the manifest file.
What is the proper way to invoke the jenkins cli?
Addendum
https://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins has a separate procedure for using the jenkins cli, but it does not explain where to obtain jenkins.jar.

I have worked out a kludgy solution. I hope someone has a better idea.
On my instance I run
curl http://www.java2s.com/Code/JarDownload/localizer/localizer-1.9.jar.zip > localizaer-1.9.jar.zip
unzip localizaer-1.9.jar.zip
curl http://central.maven.org/maven2/commons-codec/commons-codec/1.9/commons-codec-1.9.jar > commons-code-1.9.jar
java -classpath /usr/share/jenkins/webroot/WEB-INF/jenkins-cli.jar:/usr/share/jenkins/webroot/WEB-INF/remoting.jar:/usr/share/jenkins/webroot/WEB-INF/slave.jar:/usr/share/jenkins/webroot/WEB-INF/classes:localizer-1.9.jar:commons-code-1.9.jar:localizer-1.9.jar hudson.cli.CLI -s http://localhost:8080 help
I don't like it because it is super-kludgy, but it seems to work.

Related

"bash: aws: command not found" on Windows 7 in Git Bash

I'm trying to use AWS CLI to access CodeCommit. And it's sort of working. I am able to use the aws command in the Windows command prompt. However, when I try to access it using the Git Bash shell, it says
"bash: aws: command not found."
Additionally, when I try to do do a git clone in the Windows command promt, trying to access CodeCommit, it tries to use aws using the credentials helper, which also results in "aws: command not found."
I followed the instructions in the AWS documentation, which suggests some directories to add to the PATH:
https://docs.aws.amazon.com/cli/latest/userguide/awscli-install-windows.html#awscli-install-windows-path
Here's what my PATH variable looks like:
C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\;C:\Windows\System32;;C:\Program
Files\Docker
Toolbox;C:\Users\ddrayton\MyCurl;%USERPROFILE%\AppData\Local\Programs\Python\Python36\Scripts;C:\Program
Files\Amazon\AWSCLI;C:\Program Files
(x86)\Amazon\AWSCLI;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36;C:\Users\ddrayton\AppData\Local\Programs\Python\Python36\Scripts
But I'm not sure if it's a PATH problem, since the Windows command prompt has no problem accessing the "aws" command.
Any ideas?
Fixed this by simply installing the AWS CLI again but this time using Git Bash instead of the Windows command prompt.
pip install awscli
If anyone could provide some insight as to why this was necessary, it would be appreciated.
In my case, I think a recent-to-me update to the AWS CLI changed what's run to being aws.cmd (full path C:\Program Files\Amazon\AWSCLI\bin\aws.cmd)
Git Bash needs the extension aws.cmd to make it work.
In Bash, you could try typing aws.cmd vs aws. If the former works, but not the latter, you can do alias aws='aws.cmd' in your bash startup script. I don't know if it's the best solution, but it worked for me.
FWIW, I think it's related to this:
https://unix.stackexchange.com/questions/280528/is-there-a-unix-equivalent-of-the-windows-environment-variable-pathext
On Windows 10 I was installing just once from GitBash via pip install awscli --upgrade --user as described in AWS manual for CLI installation for Linux
It installed aws executables into %USERPROFILE%\AppData\Roaming\Python\Python37\Scripts
After that just add this folder to your PATH. Re-open GitBash or cmd - it should work from both places

Need to know how to use Groovy to automate a Docker build & runtime

I have a task to containerize a Spring & React web-app so that non-technical staff can make use of the container to demo the app to clients. Currently we develop on OSX & deploy to Tomcat on AWS managed by a 3rd party firm, and the non-technical staff use Windows laptops for their stuff.
So far I have bash scripts in OSX which will create a Packager container that has a Java 8 SDK & maven installed, & which will compile the app into a war file. A second script creates and initializes a mongodb container & gives it a name, and the third script creates a Tomcat/Java 8 container, loads the war file into it, links it to the mongodb container & sets it running. In bash on OSX this works fine, but I found it didn't work if I tried it in cygwin on Windows 10, and my CMD/Powershell-fu is too weak to script it in a Windows native fashion.
So, I'm trying to do the script in something that'll run on both OSX, an AWS linux server & Windows 10, & being a Java developer myself I thought of Groovy. This is my first time scripting Docker using Groovy so I've ended up resorting to structures like:
println "docker build -f Dockerfile.packager -t mycontainer .".execute().text
I wonder if Docker has a Java or Groovy API that I could plug into & do things like:
docker.build("Dockerfile.packager").tag("mycontainer")
Currently my script is determining the location of the project root & building up the Docker run command as a string, like:
File emToo = new File(System.getProperty("user.dir")+"/.m2")
String currentDirectory = new File(".").getCanonicalPath()
String projectRoot = new File(currentDirectory+"/../").getCanonicalPath()
I get an option string from the user via a command line prompt, "Do you want QA or Dev?" & then:
String dockerRunCmd = "docker run -it -v $projectRoot/:/usr/local/build/myproject:cached -v ${emToo.getCanonicalPath()}:/root/.m2:cached mycontainer $option"
println dockerRunCmd.execute().text
Currently it doesn't seem to do anything after asking for the option - it's kinda bombing out. I get the run command output to screen, & if I copy/paste that into a command line in the scripts directory it falls over saying that the parent pom can't be found. Remember though that if I run the OSX bash script to do this, it works just fine. The bash script is basically:
#! /usr/bin/env bash
CWD=`pwd`
options=$1
docker run -it -v $CWD/../:/usr/local/build/myproject:cached -v ~/.m2:/root/.m2:cached --rm mycontainer $options
...which I think amounts to the same thing, right? Where's it going wrong?
UPDATE: I've found a bug - I should have been setting emToo to
new File(System.getProperty("user.home")+"/.m2"). user.dir just picks up the current directory, & the maven .m2 directory is in the user's home, usually. Currently though, the script gives me a run command that works if I cut/paste into a command line, but which doesn't allow me to call .execute() on the string in Groovy. If I can get that to work, there'll be no need for the docker-client projects suggested.
There are different ways to communicate with docker from groovy or java (sdk's are listed there https://docs.docker.com/engine/api/sdks/#other-languages):
Groovy (https://github.com/gesellix/docker-client)
Java (https://github.com/docker-java/docker-java)
Many others can be also found on github.
But as I see you are using maven so probably it will be easier for you to use awesome docker maven plugin (https://dmp.fabric8.io) which can build, push images, run containers etc.

Running Jenkins on Tomcat Fail applicaton at context path /jenkins could not be started

For a few days I am trying to set Jenkins on Tomcat7 without any result... I read many tutorials and I could not find any help...
I set a virtual system on VirtualBox -> Ubuntu 12.04.04
Using apt-get I installed tomcat7, and then Jenkins.
While using them separately by usingcommad sudo service tomcat7 start or sudo service jenkins start both services starts and are visable on my localhost.
However, when I copied jenkins.war to /var/lib/tomcat7/webapps I cannot run it via tomcat.
I have set JENKINS_HOME as /var/lib/jenkins.
In the folder /usr/share/tomcat7 i run these commands: sudo mkdir .jenkins | sudo chown tomcat7:nogroup .jenkins
And from localhost:8080/manager jenkins is viable:
When I try localhost:8080/jenkins as tutorials says I get en error message:
I really have no idea what am I doing wrong...
What else may I try to make it work?
I had the same issue. Please check Java compatibility version with the "Jenkins.war" file. I used Java 8 for Jenkins version 2.107.1.
I would suggest to shutdown restart the tomcat server. As it should be able to read the .war file. Hence, you will go through additional setup.
Check the version of your jenkins.war file
Check the compatibe java version for hat jenkins version in web
Download that version of java and define system environment variables path for JAVA_HOME
Open "Monitor tomcat" in that JAVA define the path of jvm.dll
example C:\Program Files\Java\jdk-11.0.16\bin\server\jvm.dll
This picture shows how to run in windows:
Please check your JRE path, as I face a similar issue where JRE_HOME was incorrectly set
JRE_HOME=/usr/jdk/jdk1.6.0_21,
It started working when I correct it to latest JRE version
JRE_HOME=/usr/jdk/jdk1.7.0_09/jre.

Cannot start Jenkins server

Cannot start jenkins. giving below logs when try to restart but doesnt work -
-bash-3.2$ ./jenkins.sh start
Jenkins is currently stopped...
Starting Jenkins with command cd /eas/jenkins;/eas/jenkins/jenkins_jre/jre1.7.0_51/bin/java -Xms1024m -Xmx2048m - XX:MaxPermSize=512m -DJENKINS_HOME=/eas/jenkins/home -jar jenkins.war
-bash-3.2$ standard in must be a tty
Please help!
No, adding to sudoers file didnt solve it. there was issue with JVM where JDK was not able to initialize because of size I gave as arguments were not available, reduced and it worked.

How to start Gerrit in Windows 7 after Initialization

I did the procedures as recommended by vogella to install gerrit on windows.
I downloaded gerrit2.10.war from the releaase site
Then I created a gerrit folder in C drive
I ran the commands
cd C:/gerrit
java -jar gerrit.war init -d C:/gerrit
Then on pressing enter (i.e using default) for every questions I got the message:
Initialized C:\gerrit
Then to start I tried the command
java -jar gerrit.war daemon -d C:\gerrit
but it didnt show any message or performed any action.
On checking the error_log in logs in C:\gerrit it was shown like
ERROR com.google.gerrit.pgm.Daemon : Unable to start daemon
If someone knows to resolve this issue please help.
Thanks

Resources