Accessing Merge Settings via the GitLab API - merge

I would like to view and perhaps change the merge settings in GitLab (see the screenshot). How do I do this via the API?

If this is when creating a project there is a string named "merge_method" & "remove_source_branch_after_merge"
merge_method
remove_source_branch_after_merge
So this would be
GET /projects id/merge_method
for existing projects you can use
https://docs.gitlab.com/ce/api/projects.html#project-merge-method

Related

Reload TeamCity build configuration programatically

I am creating multiple TeamCity projects via the rest api.
After adding some Versioned Settings properties via:
teamcity/app/rest/projects/MyProject/projectFeatures
I would like to be able to reload the projects programmatically, so that the changes take effect.
I don't see anything in the rest api that can do that. Does anyone has any suggestion on how to do that?
Currently I am going to project configuration -> Versioned Settings -> Context Parameters, and I manually save the changes which triggers a reload of the configuration and applying the required settings.
AFAIK, there's no api method to reload versioned settings. However, you could try to select use settings from VCS option in Versioned Settings. It should force TeamCity to reload versioned settings on each build

Deploy changes from GitHub to Salesforce

How can I add a custom button on GitHub.com which I could click on in order to deploy changes from the Master branch to a related Salesforce.com DEV Org?
What have you tried? Have you seen https://developer.salesforce.com/blogs/2020/01/using-salesforce-dx-with-github-actions ?
You can steal sample actions from SF official repo at https://github.com/trailheadapps/lwc-recipes.
You'll need to provide the secret login URL to your target org, there are blog posts how to generate it and store in GitHub variable, for example https://tigerfacesystems.com/blog/sfdx-continuous-integration/ or https://github.com/sfdx-actions/setup-sfdx
Last but not least - to have action available for manual run (not just automated) read up about "workflow_dispatch"

Disable "commit mention ..." settings for Git repo by default

For every repository there are two "commit mention" settings enabled by default.
Is there a way to disable one of these or both by default (per project or even org) when a new repo is created?
I did not find any project or org setting in the web ui. Can this maybe done using some rest api?
Thank you
Instead of manually changing these options you can use the very same API as the WebUI does:
Endpoint:
https://dev.azure.com/{ORG}/{PROJECT-ID}/_api/_versioncontrol/UpdateRepositoryOption?__v=5&repositoryId={REPO-ID}
Request Type:
POST
Payload:
{"key":"WitResolutionMentionsEnabled","value": <true|false>}
Project ID and REPO ID (hash values) can be extracted either using the Developer Tools in your browser or using the Python API Wrapper.
I searched and tried with the related REST API (Repositories - Update) and Azure CLI (az repos), but did not find any available interface can change two option on repository settings.
Looks like, currently we have no available method to change the options of repository settings in batches. You may need to manually change these options.
If your projects really need this feature, I recommend that you can report a feature request on Developer Community. That will allow you to directly interact with the appropriate product team, and make it more convenient for the product team to collect and categorize your suggestions.

Can Gitlab expose build and coverage badges to anonymous users?

We are hosting some repository on GitHub, some other on GitLab.
Sometimes, the package is published but not the source code.
We always display build status and code coverage in README.md.
Is there a way to have build and coverage badge on GitLab always accessible to anonymous?
Since release 11.4.8 of Gitlab it's not possible to expose project's Badges through a Personnal Access Token anymore. Because of the change "
Restrict Personal Access Tokens to API scope on web requests."
The commit that removed this "workaround" was published as a security fix
An ongoing issue is currently being discussed to find another solution. Let's see how it goes.
That was followed by issue 13324
It includes:
FYI, I have a workaround for this using the GitLab API.
It assumes you have created a token in GitLab for a user (Note: That "user" needn't necessarily be Human - my use case is to display a badge on a dashboard hosted on a different VM).
<img src="https://<gitlab-uri>/<namespace>/<project>/badges/<branch>/build.svg?private_token=<token>
Update Dec. 2018: This is no loger possible through a token (see Paul B.'s answer).
This is because of "Improper Enforcement of Token Scope":
The GitLab web interface was vulnerable to an authorization issue that allowed access to the web-UI as a user using their Personal Access Token (PAT) of any scope.
The issue is now mitigated in the latest release and is assigned CVE-2018-19569.
But...:
Updated: 2018-11-28: We have received reports that this change has impacted how repo files and job artifacts are downloaded for some users.
For instructions on how to do so through the API, please see our support issue.
And you also have a current workaround which repeats the API access:
It is possible to add the project avatar to the project repository with a particular filename (logo) and then this file will be used for the avatar. There is an example here:
https://gitlab.com/issue-reproduce/project-avatar-repo
You'll be able to retrieve the files through the Repository Files API:
https://docs.gitlab.com/ee/api/repository_files.html#get-file-from-repository
Example:
https://gitlab.com/api/v4/projects/issue-reproduce%2Fproject-avatar-repo/repository/files/logo.png?ref=master

Git Repository is not visible on docker hub for automatic build

I already have 2 automatic builds on hub.docker with Dockerfiles hosted on github. They are working great. My problem is now I want to use a Dockerfile in an github repository which is not my own but I am admin and member and have full access to. I can see several other repositories on the hub.docker page when I try to create a new automatic build. They are very similar to the one I want to use but the one I want to use is not listed there, although I have full access to it. I ready through do documentation from hub.docker and I also logged in and out. Further more I also delinked my github account and relinked it. (with write persissions). So my question is how can I make the other repository visible on hub.docker in order to create an automatic build?