Bitbucket web hook not posting - push

I have set up a web hook on Bitbucket to POST to my webserver to log some details. There is two webhooks on the repo, my custom one, and one for FTPloy.com. I have been pushing random commits to test the POST on my server etc, but after a while it stopped.
Never FTPloy.com or my own webserver receives a post request from Bitbucket after I pushed.
How is this possible/how can I fix it?

I had a hard time testing my web hook as well. I figured out that the best way to test is via command line. I copied the sample data shown here, added payload= to the beginning and saved it to a file: bb.post
Then via command line I submitted a POST request to my web hook using that file as the POST data: curl --data #bb.post http://mydomain.com/customWebHook.php
This is the best way I found to debug it.
Note: They never mention that when the last commit was from a merge, the "branch" attribute from that commit is null. Instead you need to look at "branches" attribute which is an array of the two branches that created the merge.

Related

how to check any open pull request in GitHubs?

I got a coding challenge from a company and they require to complete a project on https://www.hatchways.io/
I already completed all of the code, but as I submit it shows that
{ Before you submit the Front-end Work Simulation - Hatchways Times project, you will need to pass the following pre-checks:
You must have an open pull request. ❌
You do not have multiple pull requests opened. ✅
Sorry, looks like you didn't pass all the pre-checks above. Please make sure you satisfy all the requirements before you retry. }
I have two branches one is 'main' another one is 'practice'. I already checked I don't have any pull request both of branches.
Is there anyone know how to solve it please?
Pull Request
record of pull request
Click New pull request
Set the branch to practice and the base branch to main
Submit

How to get a link to a file from a VSO repo

When I browse a GitHub repo, I can copy the URL from the browser, and I can share it like this -
https://github.com/zlatko-michailov/onesql/blob/master/lang/src/onesql.syntax.ts. The file content is returned in the http response stream without any decorations.
How can I do the same thing for a VSO repo? If I have to tweak the URL a little bit, that's OK.
I see the browser uses a REST API that is documented here - https://learn.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-5.0. I played with different combinations of includeContent, $format, download, etc., but I could only get the content as a separate download, not in the http response body.
The subject file is some CSV data, and the client is Excel, which doesn't seem to be able to handle downloads.
I solved my own problem. There is no need to create a feed.
The API that fetches raw files is sourceProviders. The link is here: https://learn.microsoft.com/en-us/rest/api/azure/devops/build/source%20providers/get%20file%20contents?view=azure-devops-rest-5.0
It is not very well documented - examples for the required parameters are missing. The tricky one is sourceProvider. It has to be tfsgit. Skipping serviceEndpointId worked for me.
Here is the pattern:
GET https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/tfsgit/filecontents?&repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=5.0-preview.1

Azure DevOps/VSTS REST API does not get changes of a changeset

I'm trying to to get the changes of a changeset but it returns 404. I used this:
https://<myname>.visualstudio.com/<projectname>/_apis/tfvc/changesets/291/changes
changeset exists
without the '/changes' it works, returns the changeset info but I also need the merge sources
tried to specify the API version (e.g.: api-version-5.0)
I created a full control Personal Access Token for the client app but no luck. I tried to use this link in the browser and I got the same result: it works only without '/changes'.
What did I wrong?
As this is an old Q, this is for anyone else who has same problem, The projectname needs to be removed from the request.
https://<myname>.visualstudio.com/_apis/tfvc/changesets/291/changes
You look at the docs and sure enough it's not there but most other REST calls require a project name, so it can be confusing.
Also the docs are not very clear that you can interchange https://{myName}.visualstudio.com/ for the documented https://dev.azure.com/{organization}

How to get the associated changes, check-in comments and linked work items for a particular build/release in VSTS

I am using SendGrid email extension to trigger a custom email notification after the CI/CD process is complete in VSTS. This email task has HTML content in it which includes some content fetched using standard build/release variables (https://learn.microsoft.com/en-us/vsts/build-release/concepts/definitions/build/variables?tabs=batch).
How do I include associated code changes, check-in comments and linked work items for a particular release in the custom email? Are there any variables I can use? Any work around?
There aren’t the built-in variables that can get code changes, check-in comments and linked work items.
You can get them through REST API during build or release:
Get build changes and work items through Get Build Changes REST API (Build id variable: Build.BuildId during build or Release.Artifacts.{Artifact alias}.BuildId during release) Note: using Build.SourceVersion to get latest version)
Git: Get commit message through Get a batch of commits by a list of commit IDs REST API
TFVC: Get check-in comment through Get list of changesets by a list of IDS REST API
To get changed items, you can use get commit with changed items or Get list of changes in a changeset REST API.
No API to get detail code changes, but you may refer to this related issue: Lines of Code modified in each Commit in TFS rest api. How do i get?
Assuming TFS (which isn't specified in the question or tags), you could also call tf.exe directly to get some of that info. If you don't care about the output format, then the output of the following command produces a report of the Changeset details.
tf vc changeset <changeset id> /loginType:OAuth /login:.,<token> /noprompt
Where <changeset id> is the numeric Build.SourceVersion, and <token> is the System.AccessToken.
Comments and source code edits listing are included in the report.
Note: the agent job has to be given the "Allow scripts to access the OAuth token" permission (check box on the Agent Job properties).
See the updated link below for details on how to access the build variables. Same content as in the question, but new link. Both currently work.
https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml

Github : Automated tagging on Merging of Pull Requests

Is there a way to trigger an automatic, custom tagging of a repository every time a pull request is merged in github ? for example...
After merging "pull request 8", id like to automatically tag the repository at that state as "$Major_Version.$pr_id".
The result might be "0.1.8".
Is this possible?
Worst case, if someone hasn't written a thing to do that yet, is to use the post-receive webhooks https://help.github.com/articles/post-receive-hooks
You'd need an internet-visible web server to do this, and some code to recognize the merge (it will have two parents) and see if it mentions a pull-request.