Is there a configuration setting to automatically display jenkins console output - jenkins

When I manually execute a jenkins job, it would save an annoying step if, upon submitting the build button, the next screen was the console output and not the project page.
Is there a configuration setting that allows this to happen?

No native option of that kind I guess. Recent jenkins builds allow a shorter way to access console output - just click on the gray/blue point left to the currently running build:
If you still think one click is annoying extra step, then next option I'd suggest is using jenkins CLI. It needs some more one-time effort though.
Have java installed on your workstation
Download jenkins-cli.jar from http://your jenkins host/jnlpJars/jenkins-cli.jar
Then you can start builds like that:
java -jar jenkins-cli.jar -s http://jenkins-url build buildname -w -s -v -p parameterN=valueN
java -jar jenkins-cli.jar -noKeyAuth -s http://jet:8080 build tst-so -w -s -v -p host2ping=google.com
Started tst-so #17
Started from command line by anonymous
Building in workspace /var/lib/jenkins/jobs/tst-so/workspace
[workspace] $ /bin/sh -xe /tmp/hudson5079113569382475588.sh
+ echo Hello from tst-so job
Hello from tst-so job
+ ping -c 6 google.com
PING google.com (216.58.209.206) 56(84) bytes of data.
64 bytes from bud02s22-in-f14.1e100.net (216.58.209.206): icmp_seq=1 ttl=54 time=51.6 ms
64 bytes from bud02s22-in-f14.1e100.net (216.58.209.206): icmp_seq=2 ttl=54 time=51.9 ms
64 bytes from bud02s22-in-f14.1e100.net (216.58.209.206): icmp_seq=3 ttl=54 time=51.8 ms
64 bytes from bud02s22-in-f14.1e100.net (216.58.209.206): icmp_seq=4 ttl=54 time=51.8 ms
64 bytes from bud02s22-in-f14.1e100.net (216.58.209.206): icmp_seq=5 ttl=54 time=51.8 ms
64 bytes from bud02s22-in-f14.1e100.net (216.58.209.206): icmp_seq=6 ttl=54 time=51.7 ms
--- google.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5009ms
rtt min/avg/max/mdev = 51.684/51.815/51.900/0.306 ms
Finished: SUCCESS
Completed tst-so #17 : SUCCESS
In my example jenkins is setup with no authentication for simplicity reason.

Related

Connection error from jenkins server and agent

I'm connecting agent node to server.
When I try connecting with jenkins server, error occurs. Below are the log.
Failed to obtain
http://12.36.123.160:8080/computer/rsp18/jenkins-agent.jnlp?encrypt=true
java.io.IOException: Invalid Http response
at sun.reflect.GeneratedConstructorAccessor3.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1950)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1945)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1944)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1514)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:523)
at hudson.remoting.Launcher.run(Launcher.java:347)
at hudson.remoting.Launcher.main(Launcher.java:298) Caused by: java.io.IOException: Invalid Http response
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1612)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:513)
... 2 more Waiting 10 seconds before retry
I thought I lost connection to internet in agent machine, but ping operation seems okay.
> root#ubuntu:~# ping -c 5 12.36.123.160 PING 12.36.123.160
> (12.36.123.160) 56(84) bytes of data. 64 bytes from 12.36.123.160:
> icmp_seq=1 ttl=59 time=0.262 ms 64 bytes from 12.36.123.160:
> icmp_seq=2 ttl=59 time=0.245 ms 64 bytes from 12.36.123.160:
> icmp_seq=3 ttl=59 time=0.259 ms 64 bytes from 12.36.123.160:
> icmp_seq=4 ttl=59 time=0.249 ms 64 bytes from 12.36.123.160:
> icmp_seq=5 ttl=59 time=0.233 ms
> --- 12.36.123.160 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4102ms rtt min/avg/max/mdev =
> 0.233/0.249/0.262/0.010 ms
connection to jenkins server is good, and my server is okay.
What's wrong with this problem?

Measure execution time of docker container

I have a docker image called my_image which launch a command and closes.
When running the image in a container using command docker run --rm my_image, is it possible to measure the execution time of the container ?
Edit :
I need to see those timing information after container execution, thus I can't use time command.
I somehow hoped to find some container execution history kept by docker even if --rm was used. But if it doesn't exist, then #tgogos' answer is suited.
The goal is to compare execution time of several images to draw a conclusion about the different tools used.
1st approach: time
time docker run --rm --name=test alpine ping -c 10 8.8.8.8
...
real 0m10.261s
user 0m0.228s
sys 0m0.044s
but this will also include the time for creating and removing the container.
2nd approach: container information
The information you are looking for is stored by docker and can be reached by docker container inspect.
docker run --name=test alpine ping -c 10 8.8.8.8
* notice that I didn't use --rm because the next step is to inpect the container. You will have to remove it afterwards. The timestamps you might be interested in are:
"Created": "2018-08-02T10:16:48.59705963Z",
"StartedAt": "2018-08-02T10:16:49.187187456Z",
"FinishedAt": "2018-08-02T10:16:58.27795818Z"
$ docker container inspect test
[
{
"Id": "96e469fdb437814817ee2e9ad2fcdbf468a88694fcc998339edd424f9689f71f",
"Created": "2018-08-02T10:16:48.59705963Z",
"Path": "ping",
"Args": [
"-c",
"10",
"8.8.8.8"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 0,
"ExitCode": 0,
"Error": "",
"StartedAt": "2018-08-02T10:16:49.187187456Z",
"FinishedAt": "2018-08-02T10:16:58.27795818Z"
}
...
Duration calculation example (with bash):
You can put these timestamps in bash variables with single commands like this:
START=$(docker inspect --format='{{.State.StartedAt}}' test)
STOP=$(docker inspect --format='{{.State.FinishedAt}}' test)
Then you can convert them to UNIX epoch timestamps (seconds since Jan 01 1970. (UTC))
START_TIMESTAMP=$(date --date=$START +%s)
STOP_TIMESTAMP=$(date --date=$STOP +%s)
and if you subtract these two, you get the duration in seconds...
echo $(($STOP_TIMESTAMP-$START_TIMESTAMP)) seconds
9 seconds
You have to consider a couple of things:
How to get time execution of a process given a PID.
Execute docker exec specifying PID=1 because container time running = entrypoint running.
Combining two things you get docker container time execution with:
docker exec -ti <container_id> ps -o etime= -p "1"
It gives you more accuracy than column STATUS of docker ps command.
If you're executing several processes in container and you need execution time for any of them, just replace "1" by its PID inside container.
Another possible approach may be to override the default entrypoint with the time command.
$ docker run --rm --name=test --entrypoint=time alpine ping -c 10 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=37 time=51.213 ms
64 bytes from 8.8.8.8: seq=1 ttl=37 time=7.844 ms
64 bytes from 8.8.8.8: seq=2 ttl=37 time=8.120 ms
64 bytes from 8.8.8.8: seq=3 ttl=37 time=10.859 ms
64 bytes from 8.8.8.8: seq=4 ttl=37 time=10.975 ms
64 bytes from 8.8.8.8: seq=5 ttl=37 time=12.520 ms
64 bytes from 8.8.8.8: seq=6 ttl=37 time=7.994 ms
64 bytes from 8.8.8.8: seq=7 ttl=37 time=8.904 ms
64 bytes from 8.8.8.8: seq=8 ttl=37 time=6.674 ms
64 bytes from 8.8.8.8: seq=9 ttl=37 time=7.132 ms
--- 8.8.8.8 ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 6.674/13.223/51.213 ms
real 0m 9.02s
user 0m 0.00s
sys 0m 0.00s
Doing this won't include the container start up time. You can even do something like:
time docker run --rm --name=test --entrypoint=time alpine ping -c 10 8.8.8.8 to see how long just the container startup takes.

Mule project is not showing on http://0.0.0.0:8080 after deployment in docketed container

Mule container is running as per following log :details are in code block.
INFO 2017-08-20 14:53:50,580 [WrapperListener_start_runner] org.mule.runtime.module.launcher.MuleContainer:
**********************************************************************
* Mule Runtime and Integration Platform *
* Version: 4.0.0-BETA.4 Build: c03a2009 *
* MuleSoft, Inc. *
* For more information go to https://developer.mulesoft.com/ *
* *
* Server started: 8/20/17 2:53 PM *
* JDK: 1.8.0_131 (mixed mode) *
* OS: Linux (4.4.0-1022-aws, amd64) *
* Host: b2c75bd67158 (172.17.0.2) *
* Mule services: *
* - mule-service-oauth-1.0.0-BETA.4.zip *
* - mule-service-scheduler-1.0.0-BETA.4.zip *
* - mule-service-soap-1.0.0-BETA.4.zip *
* - mule-service-http-1.0.0-BETA.4.zip *
* - mule-service-weave-2.0.0-BETA.4.zip *
* Mule system properties: *
* - mule.base = /opt/mule *
* - mule.home = /opt/mule *
**********************************************************************
INFO 2017-08-20 14:53:50,584 [WrapperListener_start_runner] org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer: Initializing core extensions
INFO 2017-08-20 14:53:50,584 [WrapperListener_start_runner] org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer: Starting core extensions
INFO 2017-08-20 14:53:51,113 [WrapperListener_start_runner] org.mule.service.scheduler.internal.DefaultSchedulerService: Starting org.mule.service.scheduler.internal.DefaultSchedulerService#3cb32d0e...
INFO 2017-08-20 14:53:51,127 [WrapperListener_start_runner] org.mule.service.scheduler.internal.DefaultSchedulerService: Started org.mule.service.scheduler.internal.DefaultSchedulerService#3cb32d0e
INFO 2017-08-20 14:53:51,134 [WrapperListener_start_runner] org.mule.service.scheduler.internal.config.ContainerThreadPoolsConfig: Loading thread pools configuration from /opt/mule/conf/scheduler-pools.conf
INFO 2017-08-20 14:53:51,838 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.DefaultArchiveDeployer: ================== New Exploded Artifact: default
INFO 2017-08-20 14:53:51,911 [WrapperListener_start_runner] org.mule.runtime.module.deployment.impl.internal.domain.DefaultMuleDomain:
**********************************************************************
* Started domain 'default' *
**********************************************************************
INFO 2017-08-20 14:53:51,913 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.DeploymentDirectoryWatcher:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ Mule is up and kicking (every 5000ms) +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
INFO 2017-08-20 14:53:51,916 [WrapperListener_start_runner] org.mule.runtime.module.deployment.internal.StartupSummaryDeploymentListener:
**********************************************************************
* - - + DOMAIN + - - * - - + STATUS + - - *
**********************************************************************
* default * DEPLOYED *
**********************************************************************
Did some investigation
ubuntu#ip-172-31-27-212:/opt$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b2c75bd67158 testing "/opt/mule/bin/sta..." 2 minutes ago Up 2 minutes 443/tcp, 1098-1099/tcp, 5000/tcp, 5701/tcp, 7777/tcp, 8899/tcp, 54327/tcp, 0.0.0.0:8080->8080/tcp dazzling_kalam
ubuntu#ip-172-31-27-212:/opt$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' b2c75bd67158
172.17.0.2
ubuntu#ip-172-31-27-212:/opt$ netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
default ip-172-31-16-1. 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 * 255.255.0.0 U 0 0 0 docker0
172.31.16.0 * 255.255.240.0 U 0 0 0 eth0
ubuntu#ip-172-31-27-212:/opt$ ping 0.0.0.0
PING 0.0.0.0 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.033 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.034 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.034 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.036 ms
^C
--- 0.0.0.0 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 5998ms
rtt min/avg/max/mdev = 0.033/0.035/0.038/0.005 ms
ubuntu#ip-172-31-27-212:/opt$ ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.068 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.045 ms
64 bytes from 172.17.0.2: icmp_seq=3 ttl=64 time=0.044 ms
64 bytes from 172.17.0.2: icmp_seq=4 ttl=64 time=0.046 ms
^C
--- 172.17.0.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms
rtt min/avg/max/mdev = 0.044/0.050/0.068/0.013 ms
To run docker container
docker run -ti --rm -p 8080:8080 -v /home/ubuntu/dockerfiles:/opt/mule/apps $CONTAINER_TEST_IMAGE
Placed mule project artifact inside from dockerfile
WORKDIR /opt/mule
COPY mule-template-project-api-1.0.0-SNAPSHOT.zip /opt/mule/apps/hello-world.zip
After all or running mule container if I am trying my application on is showing
ubuntu#ip-172-31-27-212:~$ curl http://0.0.0.0:8080
curl: (56) Recv failure: Connection reset by peer
ubuntu#ip-172-31-27-212:~$ docker exec -it f71e9bfa8f9d curl localhost:8080
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:262: starting container process caused "exec: \"curl\": executable file not found in $PATH"
ubuntu#ip-172-31-27-212:~$ docker exec -it f71e9bfa8f9d curl 0.0.0.0:8080
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:262: starting container process caused "exec: \"curl\": executable file not found in $PATH"

docker-compose replica hostname

I am trying to add a cluster with replicas using docker-compose scale graylog-es-slave=2 but for a version 3 Dockerfile unlike Docker compose and hostname
What I am trying to do ix figure out how to get the specific node in the replica set
Here is what I have tried
D:\p\liberty-docker>docker exec 706814bf33b2 ping graylog-es-slave -c 2
PING graylog-es-slave (172.19.0.4): 56 data bytes
64 bytes from 172.19.0.4: icmp_seq=0 ttl=64 time=0.067 ms
64 bytes from 172.19.0.4: icmp_seq=1 ttl=64 time=0.104 ms
--- graylog-es-slave ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.067/0.085/0.104/0.000 ms
D:\p\liberty-docker>docker exec 706814bf33b2 ping graylog-es-slave.1 -c 2
ping: unknown host
D:\p\liberty-docker>docker exec 706814bf33b2 ping graylog-es-slave_1 -c 2
ping: unknown host
The docker-compose.yml
version: 3
service:
graylog-es-slave:
image: elasticsearch:2
command: "elasticsearch -Des.cluster.name='graylog'"
environment:
ES_HEAP_SIZE: 2g
deploy:
replicas: 2 <-- this is ignored on docker-compose just putting it here for completeness
Instead of ., use _ (underscore), and add the prefix of the project name (the directory that holds your docker-compose.yml, I assume that it is liberty-docker_graylog):
ping liberty-docker_graylog-es-slave_1
You can see that doing network ls, search for the right network, then docker network inspect network_id.

There is a way to ping a Docker container using its hostname, from another Docker Container?

I am looking for a solution to ping a Docker container using its hostname, from another Docker Container.
I tried as follow:
starting first Docker container:
docker run --rm -ti --hostname=repohost --name=repo repo
starting second Docker container, link to first and start bash:
docker run --rm -ti --hostname=repo2host --link repo:rp repo2 /bin/bash
on bash started on repo2
ping repohost
it remain on pending without any result.
Can someone tell me if there is a solution for this?
You should be able to ping using the alias you gave in the link command (the part after the :), in your case ping rp should work.
The following works for me, given a running container called furious_turing:
$ docker run -it --link furious_turing:ft debian /bin/bash
root#06b18931d80b:/# ping ft
PING ft (172.17.0.3): 48 data bytes
56 bytes from 172.17.0.3: icmp_seq=0 ttl=64 time=0.136 ms
56 bytes from 172.17.0.3: icmp_seq=1 ttl=64 time=0.091 ms
56 bytes from 172.17.0.3: icmp_seq=2 ttl=64 time=0.092 ms
^C--- ft ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.091/0.106/0.136/0.000 ms
root#06b18931d80b:/#
If you need to ping on another name, you can add entries to /etc/hosts with the --add-host argument to docker run.
One way to achieve what you need would be with WeaveDNS.

Resources