I want a telegram message from jenkins whenever there is a new build.
I tried integrating telegram bot with jenkins by referring the jenkins plugin documentation : https://wiki.jenkins.io/display/JENKINS/Telegram+Notification+Plugin
But this did not work. Is there any other way of doing this?
You can just add step to execute shell script and send message via curl:
$ curl -s -X POST https://api.telegram.org/bot[TOKENID]/sendMessage -d chat_id=[ID] -d text="your message"
where [TOKENID] is your token id, and [ID] your chat id.
And your telegram-bot must started by user(or added to chat).
Related
In Jenkins, I would like to execute my scriptler script via REST API from bash and curl. According to documentation it should work, but there isn't any working example.
I have created simple script testScr, which is just one liner: println "OK". I'm trying to execute it with curl:
curl -d '{}' --user <userid>:<Token> http://<jenkins_server>/scriptler/run/testScr > result.html
Resulting html says: "Oops! A problem occurred while processing the request."
How to do it correctly? Is even it working for somebody?
Yes that works for me.
Have you made sure that the user have the right permission and the token is corrct?
In my case I'm using Role-based Authorization Strategy
And you can execute it if you're admin
if you want another user different that admin execute it you can also grant permissions
If you deploy using the command below,
twilio flex:plugins:deploy --changelog='first deploy'
The following error will occur.
I don't understand the meaning of the path pointed to by resource.
Error code 20404 from Twilio: The requested resource /Services/ZSXXXXXXXXXXXXXXXXXXXXXXX/Environments was not found. See https://www.twilio.com/docs/errors/20404 for more info.
This is the first deployment that has not been deployed yet.
What should i do?
twilio serverless:deploy
Using the above command, functions and assets are deployed on a serverless basis.
At that time, I have deleted the Services of functions and assets that existed by default.
Is this default Services relevant for plugins?
Also, if it is related, where is the part to reset in the plug-in?
When I contacted support, they told me to run the reset command.
curl https://flex-api.twilio.com/v1/Configuration \
-H "Content-Type: application/json" \
-d '{"account_sid":"ACCOUNT_SID", "serverless_service_sids": []}' \
-u ACCOUNT_SID:AUTH_TOKEN
If you deploy again after executing the above command
I was able to deploy without problems.
I am trying to make a request to the Jenkins API. However, I always get a 401 unauthorized error. I have tried all permutations of requests using Curl - including sending the API token and Crumb. The Jenkins is hosted on a DEV server and not on my local. I have CSRF protection enabled on Jenkins. Could this be a CORS issue or something else?
Thanks
Trigger Jenkins build with parameters using API token
Variables
UserName is the user with permission to execute jobs
UserTokenValue is the token key assigned to UserName.
JobTokenValue is the token key assigned to the job to allow remote execution.
Create User Token - if jenkins instance requires authorization to execute jobs then user token will be required or the error "missing bread crumb trail" may appear.
Login to Jenkins
Click username in top right corner
Click configure
Click add token
Capture the UserTokenValue. Note:Token id will not be needed going forward.
Optional - verify token assigned to user.
Command curl -v -u <user>:<userTokenValue> <jenkins>/user/<user>/api/json
Example curl -v -u john:11bc70579c86512be9a4356127640abfda http://jenkins.dv.local:8080/user/john/api/json
Enable Jenkins Job to "Trigger builds remotely (e.g., from scripts)"
Locate Jenkins job and click Configure
Scroll to the "Build Triggers" section and enable the checkbox "Trigger builds remotely"
Enter a secret "Authentication Token" in the text box. The Token is required to execute this specific job remotely. Use "SuperSecret"
Because the Token is set in this one job configuration, that value will only allow this one job to execute remotely.
Use the same value for all jobs if you like but there is no way to manage the JobTokenValue Globally that I know of.
Execute job with parameters using Curl POST
Your values will vary...
JenkinsUrl : https://jenkins.dv.local:8080
UserName : john
UserTokenValue : 115e46b2109bda095cc070b6347dafe585
JobTokenValue : SuperSecret
Command
curl -X POST <JenkinsUrl>/job/test/build -user <UserName>:<UserTokenValue> --data token=<JobTokenValue> --data parm1Name=parm1Value --data parm2Name="Parm2Value with spaces"
Example
curl -X POST http://jenkins.dv.local:8080/job/MyRemoteJob/buildWithParameters --user john:115e46b2109bda095cc070b6347dafe585 --data token=SuperSecret --data TEST_PLAN_KEY=QTAK-1040 --data BROWSER="Chrome (headless)"
401 probably means your username/pass are incorrect.
This works for me:
curl -v -X GET "http://$JENKINS_URL/crumbIssuer/api/json" --user $USERNAME:$USERPASS
If there is a CORS issue, use https://plugins.jenkins.io/cors-filter/.
I am trying to execute a Jenkins job via slack.
I have integrated the command and the URL that I pass in the command is working via command line.
The same URL when I put in web browser is giving the error
Access Denied
Invalid Token Specified
[root#ip-172-31-40-187 jobs]# curl http://13.127.223.19:8080/job/startApacheServer/build?token=mytoken --user "piyu:1128fcb12815c3d891ed43dd4b982636e6"
[root#ip-172-31-40-187 jobs]# echo $?
0
The same is not working when I put it in browser and also slack commands exit with a status of 403
I have one jenkins server A where I am trying to create a scripted pipeline but I have to call another job (Job1) on another jenkins server B.
In order to do that I am using REST API with crumb in Header. I retrieve my crumb by running the following command on my browser.
http://myhudson.com/crumbIssuer/api/json?xpath=concat(//crumbRequestField,":",//crumb)"
I tried different commands mentioned below but there is no luck.Please advise some thing. I do have access or permission for triggering build on both of the servers. I am executing below commands from Jenkins server A with details of Server B.
1. curl -v -u Username:<API_TOKEN> -X POST http://UsedrName:<API_TOKEN>#myjenkins.com/job/Test_job/build?token=<API_TOKEN> -H Jenkins-Crumb:<Crumb number>
2. curl -v -X POST http://UsedrName:<API_TOKEN>#myjenkins.com/job/Test_job/build?token=<API_TOKEN> -H Jenkins-Crumb:<Crumb number>
3. curl -v -u Username:<API_TOKEN> -X POST http://UsedrName:<API_TOKEN>#myjenkins.com/job/Test_job/build?token=<API_TOKEN> -H .crumb:<Crumb number>
did jenkins API work for you, https://wiki.jenkins.io/display/JENKINS/Remote+access+API you can trigger remote jobs
You need to use Build With Parameters Plugin for it . you can write a shell script in build option to call the another jenkins job on other server.
shell script snippet :curl -X POST -u userid of other server:API token of other server {jenkins server url of B job /job/jobname}
To get rid of this error i got Jenkins-Crumb by using wget command.
Trigger parameterized build with curl and crumb
I was able to execute remote parameter job.
I faced the same issue and it was because on that port something else is running and jenkins is giving Error as "No Valid crumb is included in that request" thus changed the port in server.xml and things worked.