Getting wrong information from github payload - github

I am trying to pull the committer's email address from the payload but the payload is showing some default value like
"noreply#server_ip"
I am trying to parse the committer's email address from the payload but the payload is delivering like this below :
"author": {
"name": "XYZ",
"email": "XYZ#abc.com",
"username": "xyz"
},
"committer": {
"name": "GitHub Enterprise",
"email": "noreply#server_ip"
The jenkins pipeline is showing like this
"fullName":"noreply"},"authorEmail":"noreply#server_ip"
My code is
authemail = parsedJson.changeSets.items.authorEmail[0]
Not able to understand is there a problem in Jenkins or Github settings ?
Any help/advice is appreciated.
My code is
authemail = parsedJson.changeSets.items.authorEmail[0]
"author": {
"name": "XYZ",
"email": "XYZ#abc.com",
"username": "xyz"
},
"committer": {
"name": "GitHub Enterprise",
"email": "noreply#server_ip"

The GitHub server,for that account, might have set a noreply email address.
If you'd like to keep your personal email address private, you can use a GitHub-provided no-reply email address as your commit email address.
To use your noreply email address for commits you push from the command line, use that email address when you set your commit email address in Git.
To use your noreply address for web-based Git operations, set your commit email address on GitHub and choose to Keep my email address private.

Related

AWS Chatbot <--> Slack integration

I am trying to configure AWS Chatbot to receive messages from SNS (using AWS eventbridge)
My chatbot is configured correctly with slack and when I publish a test message I receive it in my slack channel.
When SNS publishes a message, sometimes I receive it to my slack channel and sometimes I am getting an error: 'Event received is not supported' with the following body:(Cloudwatch logs)
Event received is not supported (see https://docs.aws.amazon.com/chatbot/latest/adminguide/related-services.html ):
{
"subscribeUrl": null,
"type": "Notification",
"signatureVersion": "1",
"signature": <Some_Sig>,
"topicArn": <Some_ARN>,
"signingCertUrl": <Some_Cert>,
"messageId": "765d31b5-0c37-5294-a78d-6acae9d14ea9",
"message": "asd asd adasd asd asa",
"subject": "aweq",
"unsubscribeUrl": "https://sns.eu-west-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:eu-west-1:<Some_ARN>:***REDACTED***",
"timestamp": "2022-08-24T08:39:02.294Z",
"token": null
}
Can someone please assist?
Thanks in advance

Create GitHub service connection using azure rest api giving error

I am trying to create GitHub service connection using azure Devops rest api -
In postman I put following Json Body-
{
"name": "release-1",
"type": "github",
"url": "https://github.com",
"authorization": {
"scheme": "PersonalAccessToken",
"parameters": {
"accessToken": "<Github_Personal_Access_Token>"
}
}
}
This Creates service connection but It gives error when I open service connection in UI and try to verify but if I edit and replace with same Github token In UI then it works. seems like its not taking token I am providing in Json body -
I also see information here on this ongoing issue - https://ljvmiranda921.github.io/notebook/2019/12/28/workaround-azure-github-pat/
I want to automate GitHub service connection creation.
How to create GitHub service connection using Azure Devops rest api ?
How to create GitHub service connection using Azure Devops rest api ?
Are you creating this GitHub service connection?
If so, you should use EndPoints-Create API and your Json Body can follow this format:
{
"authorization": {
"scheme": "Token",
"parameters": {"AccessToken": "YourGitHubPAT"}
},
"data": {},
"description": "",
"name": "YourServiceConnectionName",
"serviceEndpointProjectReferences": [{
"description": "",
"name": "YourServiceConnectionName",
"projectReference": {
"id": "YourProjectID",
"name": "YourProjectName"
}
}],
"type": "github",
"url": "https://github.com",
"isShared": false
}
We should enter the value of YourGitHubPAT, YourServiceConnectionName(twice in two points), YourProjectID and YourProjectName with your own values to make the body work. We can get YourProjectID via Projects-List API.
After running that in PostMan, I can verify it successfully without issues. I guess your issue may have something to do with your parameters. Use
"authorization": {
"scheme": "Token",
"parameters": {"AccessToken": "<Github_Personal_Access_Token>"}
},
Instead of
"authorization": {
"scheme": "PersonalAccessToken",
"parameters": {"accessToken": "<Github_Personal_Access_Token>"}
Update about how to enable grant access to all pipelines:
Dislike other elements like Token, Name and Description, Grant Access Permissions to all pipelines option is managed by another API.
API to enable this option:
https://dev.azure.com/{YourOrganizationName}/{YourProjectName}/_apis/pipelines/pipelinePermissions/endpoint/{YourEndPointID}?api-version=5.1-preview.1
Body:
{
"resource": {
"id": "YourEndPointID",
"type": "endpoint",
"name": ""
},
"pipelines": [],
"allPipelines": {
"authorized": true,
"authorizedBy": null,
"authorizedOn": null
}
}
Note: We need to enter EnterPointID in URL and Body. (Twice!)
In PostMan, you should use PATCH method and application/json type. The YourEndPointID is ServiceConnectionID, you can get this value from EndPoints-Create API's response.
So normally to create a service connection with "Grant Access to All..." enabled, we should run Endpoints-Create first and then run the second API to enable this option.
(And this is the same behavior in Web Portal. When we click Verify and Save button in web browser, it actually also calls these two APIs to complete the process.)

Azure DevOps service hook - "build for ![repo item].... ![Branch icon]"

I've just set up a service hook for one of the projects in our on-site DevOps server, that uses a "Incoming Webhook" connector to an Outlook Group.
The hook seems to work fine - I'm getting the notifications I'm expecting through just fine. However, there seems to be an issue with what I assume is supposed to be graphics.
For example, for the "build succeeded" service hook, I receive the following email:
Looking at the status message, it states:
"Build for !Repo Icon.... !Branch Icon..."
I assume these are SUPPOSED to be images, but I can't figure out why they're not being shown as such?
Examining the request JSON that is sent from DevOps to Office 365, I can see it's passing through that specific text, but I think its being perceived as a link markdown, rather than an image:
"text": "Build for ![Repo Icon](https://cdn.vsassets.io/content/notifications/teams-pushrepo.png) [JamalHartnettUserBranch](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/_git/71777fbc-1cf2-4bd1-9540-128c1c71f766) ![Branch Icon](https://cdn.vsassets.io/content/notifications/teams-branch.png) [master](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/_git/71777fbc-1cf2-4bd1-9540-128c1c71f766/#version=GBmaster), finished 04/07/2015 17:24:20 UTC"
Anyone have an idea how I'd fix this?
I know there's a specific Azure DevOps connector, but that only works with cloud-based DevOps instances, not private on-site ones (at least, as far as I can tell)
For reference, here's the full json request message (with private urls removed):
Method: POST
URI: https://outlook.office.com/webhook/<obfuscated>/IncomingWebhook/<obfuscated>/<obfuscated>
HTTP Version: 1.1
Headers:
{
Content-Type: application/json; charset=utf-8
}
Content:
{
"sender": "Azure DevOps Services",
"summary": "Build 20150407.2 - succeeded",
"themeColor": "#107c10",
"title": null,
"text": null,
"sections": [{
"title": null,
"markdown": true,
"images": null,
"activityTitle": "[CustomerAddressModule / 20150407.2](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Builds/1) (Succeeded)",
"activitySubtitle": "Trigger: batchedCI for [Jamal Hartnett](mailto:Jamal.Hartnett#Fabrikamcloud.com)",
"text": "Build for ![Repo Icon](https://cdn.vsassets.io/content/notifications/teams-pushrepo.png) [JamalHartnettUserBranch](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/_git/71777fbc-1cf2-4bd1-9540-128c1c71f766) ![Branch Icon](https://cdn.vsassets.io/content/notifications/teams-branch.png) [master](https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/_git/71777fbc-1cf2-4bd1-9540-128c1c71f766/#version=GBmaster), finished 04/07/2015 17:24:20 UTC",
"activityImage": "https://cdn.vsassets.io/content/notifications/teams-build-succeeded.png",
"activityImageType": "article"
}],
"potentialAction": [{
"#context": "http://schema.org",
"#type": "ViewAction",
"name": "View build",
"target": [
"https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/71777fbc-1cf2-4bd1-9540-128c1c71f766/_apis/build/Builds/1"]
}]
}

How to use github api from postman

i want to create a file on my github account using github api through postman.
github api to create a file on github account:
PUT /repos/:owner/:repo/contents/:path
can anyone tel me how to use this api in postman.
i have my public github account : https://github.com/ritzygithub/myfirstRepo
and in postman header i set
Authorization type to OAuth 2
Authorization : token <token>
PUT request with url: https://api.github.com/repos/ritzygithub/myfirstRepo/
Can you please help me out in this
i just figured it out.. posting my answer here so that if anyone is facing same issue then this can help them.
In postman, set as PUT request with below URL
https://api.github.com/repos/YourUsername/YourRepo/contents/file.txt
Add Body:
{
"message": "my commit message",
"committer": {
"name": "My name",
"email": "my email"
},
"content": "base64encoded"
}
Header:
Content-Type : application/json
Authorization : token
Refer below Screenshot:
Hope this helps.
Thanks

Updating request destination name and address

I'm trying to set a request destination name and address.
I'm using following request:
PATCH /requests/{request_id} with end_address and end_nickname:
{
"end_latitude": -29.951063378432128,
"end_longitude": -90.07152712622717,
"end_nickname": "Tristan Testing",
"end_address": "Tristan Testing"
}
It returns: 204 No Content, so expecting no error.
Then, if I get latest destination details:
"destination": {
"latitude": -29.9510633784,
"eta": 8034,
"longitude": -90.0715271262
}
Destination coordinates are updated fine, but nickname and address not set anywhere.
How can I solve this issue? Thanks.
Ends up the issue is only for sandbox, as in name and address for pickup and destination are not exposed on sandbox, accoding to Uber API documentation.