I'm running Jenkins in Linux and I want to raise defects in QC when the build fails. What's the easiest way to do that?
QC has a REST API that you can use, actually with anything that talks via HTTP, e.g.
curl -b qc_cookies -c qc_cookies -u <USERNAME:PASSWORD> http://<QC_SERVER:PORT>/qcbin/authentication-point/authenticate
curl -b qc_cookies -c qc_cookies -H "Content-Type: application/xml" -X POST -d #<QC_DEFECT_PAYLOAD.xml> http://<QC_SERVER:PORT>/qcbin/rest/domains/<DOMAIN>/projects/<PROJECT>/defects
curl -b qc_cookies -c qc_cookies http://<QC_SERVER:PORT>/qcbin/authentication-point/logout
More details on how to use it with Jenkins can be found at http://antagonisticpleiotropy.blogspot.com.au/2014/02/jenkins-hps-alm-quality-center-qc-rest.html
Related
I am new to TensorFlow (using 1.13) and trying to build a TF model and serve it on a docker tensor flow model server.
I have exported my model, installed docker and started my docker container with the command:
docker run -p 8501:8501 --name SN_TFlow
--mount type=bind,source=/tmp/service_model/export,target=/models
-e MODEL_NAME=1596551653 -t tensorflow/serving &
I can see my container running and the line: "I tensorflow_serving/model_servers/server.cc:375] Exporting HTTP/REST API at:localhost:8501 ..." in the client which seems to indicate all is up and running according to the doc.
However when I try to test my model with the curl command:
$ curl -d ‘{"test_value": [40]}' \ -X POST http://localhost:8501/1/models/1596551653:predict
I get a message saying:
URL bad/illegal format or missing url
Could not resolve host POST
and I get a 404 message.
I also tried simply curl http://localhost:8501/models/1/1596551653 but also get Not found.
Any idea what I am missing? Thanks
The problem I observe in your code is the \ in the middle of the curl command.
The backslash, \ should occur at the end of the line, if the command is more than one line.
So, the below command,
$ curl -d ‘{"test_value": [40]}' \ -X POST
http://localhost:8501/1/models/1596551653:predict
should be changed as shown below (move the backslash to the end) :
$ curl -d ‘{"test_value": [40]}' -X POST \
http://localhost:8501/1/models/1596551653:predict
Also, we suggest you to upgrade to the Latest Version of Tensorflow in 1.x, which is 1.15 or to 2.3.0.
Can someone explain me, how can I use sh-commands inside container without enter that container?
I use a shell script at my host. I want this shell-script to enter one of my container and then curl post to another container through overall network. So, my problem is that when i tring to do something like:
docker exec -ti nodejs sh "curl -X POST \
http://tgbot:3017/deploy \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'cache-control: no-cache' \
-d 'message=Prod has been updated!'"
I have in console:
sh: 0: Can't open curl -X POST http://tgbot:3017/ -H 'Content-Type: application/x-www-form-urlencoded' -H 'cache-control: no-cache' -d 'message=Prod has been updated!'
failed to resize tty, using default size
Or mayby I can curl into docker network right from host somehow?
You can just use Docker exec command on the host machine.
docker exec -it <container name> <command>
Is there any docker command to only list the names of repositories in docker hub registry?
I didn't find any on docker.io platform.
It's not supported by default, but you can make your own script that contains multiple function in order to list repo names as well as the images within your acccount.
It can be a simple Bash Script or can embedded to your app as a tool to search repos.
Get your authToken by login to dockerHub
Using the authToken you can invoke repo listing under your account.
AuthToken=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${username}'", "password": "'${password}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
curl -s -H "Authorization: JWT $AuthToken" https://hub.docker.com/v2/repositories/${username}/?page_size=100 | jq -r '.results|.[]|.name'
I refer to this script from github.
I want to run ZAP as a proxy in my pipeline, and run my selenium tests through the proxy. Im just using curl in a container in place of selenium for my testing and was able to make this work locally using docker.
In my pipeline, zap starts up, but the pipeline just sits in the zap container after that, never progressing to the second container. I understand why, Ive launched a process as a daemon, its never going to finish, so the step never finished. I just dont understand how to accomplish what I need in jenkins.
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090') { c ->
docker.image('owasp/zap2docker-weekly').inside("-v $WORKSPACE:/zap/wrk:rw") {
/* Wait until mysql service is up */
sh """
zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
"""
}
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090 \
-X POST https://my.fqdn.net/api/rest/sessions \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
I essentially need to start zap with the command im using in the 'inside', and only kill the container when the second containers stages are complete.
You could directly pass the zap command in the withRun part:
stage('Run Zap Proxy'){
docker.image('owasp/zap2docker-weekly').withRun('-p 8090:8090 -v $WORKSPACE:/zap/wrk:rw', 'zap.sh -daemon -port 8090 -host 0.0.0.0 -newsession testing -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true') { c ->
docker.image('cfmanteiga/alpine-bash-curl-jq').inside("--link ${c.id}:proxy") {
sh 'curl -k -x http://proxy:8090 https://my.fqdn.net'
sh """
curl -k -x http://proxy:8090 \
-X POST https://my.fqdn.net/api/rest/sessions \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"username":"username","password":"password"}'
"""
sh 'sleep 2m'
sh 'curl -o report.html http://zap/UI/core/other/htmlreport'
stash includes: 'report.html', name: 'report'
}
}
}
withRun allows you to overwrite the CMD of the zap-container. Check this API-documentation.
At the moment of writing, docker checkpoint feature is still in experimental phase so there is no official (HTTP) API documentation. Nonetheless, there is an endpoint on the docker daemon that can accept an HTTP request, as it is the one that docker cli uses.
Based on the related docker source code it should be something like
sudo curl -X POST --unix-socket /var/run/docker.sock http://localhost/v1.32/containers/20fb4f16ff10/checkpoints
but this does not work. Any ideas what I may be missing?
The create options is missing.
curl --unix-socket /var/run/docker.sock \
-H "Content-Type: application/json" \
-d '{"CheckpointID": "noting"}' \
-X POST http:/v1.32/containers/20fb4f16ff10/checkpoints