Is there an easy way to remove all the previous pipelines runned in Gitlab?
I would like to clean up this section, but didn't find any options through the interface.
Thanks a lot.
You can only delete individual pipelines one by one in the UI.
To do bulk deletions, you can use the pipelines API to programmatically list and delete pipelines.
In Python (with the python-gitlab library) it might look something like this:
import gitlab
project_id = 1234
gl = gitlab.Gitlab('https://gitlab.example.com', private_token='My token')
project = gl.projects.get(project_id)
for pipeline in project.pipelines.list(as_list=False):
pipeline.delete()
Related
I'm in search for some help on how to use TFVC commands within a Pipeline task to automatically create a new branch from an existing branch.
I need to find a way to take a copy of our golden copy code base and move it to a new branch for developers to work on.
Is there a way to do this using Pipelines and TFVC commands and\or REST API commands?
Please let me know.
Thank you in advance.
I would say what you are looking for is this
https://learn.microsoft.com/en-us/cli/vsts/install?view=vsts-cli-latest
you should be able to install that onto the pipeline machine via a step.
That should then get you a cli so you can run the commands. Then you should be able to use this link to help complete the task
https://learn.microsoft.com/en-us/azure/devops/repos/tfvc/branch-command?view=azure-devops
We have an existing AzureDevOps CI/CD. For every project, we have to manually set it up and add the job agent tasks one by one for each project.
Now, we decided to use IaC to auto deploy it using Terraform (as we have been using it for other projects as well). But there isn't much of documentation available there yet aside from this. It does have information on how to provision the project itself, but not the pipelines and other stuffs there, kind of limited at the moment, or I may have just not been able to find the complete documentation of the resources available.
We are keen to use Terraform for automating the creation of our CI/CD infrastructure, I just can't create agent jobs and tasks.
we ended up creating our own forked off of this last year, and added things that were missing, like service connections and things like that.
However, for the pipelines and such Azure DevOps is expecting you to use azure-pipelines.yml for the actual pipeline definition.
To have a build defined by Terraform and Azure something like this would work:
resource "azuredevops_build_definition" "build_definition" {
project_id = azuredevops_project.project.id
name = "My Awesome Build Pipeline"
path = "\\"
repository {
repo_type = "TfsGit"
repo_name = azuredevops_azure_git_repository.repository.name
branch_name = azuredevops_azure_git_repository.repository.default_branch
yml_path = "path to your azure-pipelines.yaml file in the repo"
}
}
So within the repo you are running the terraform from just have azure-pipeline.yaml describing the pipeline you wish to execute.
Damian Brady has a good blog on this from October 2 years ago:
https://damianbrady.com.au/2018/10/10/what-yaml-do-i-need-for-azure-pipelines/
There is also a lot of documentation around the supported Azure DevOps YAML Schema:
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema
Once comfortable with the basics you can start to look towards using templates if there are seemingly common patterns you find:
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#template-references
Hope this helps!
We are building a set of serverless functions in Azure, but having difficulty deciding how to structure our source (Azure GIT) and DevOps to support them.
I am thinking of a single GIT repo, with all function apps housed independently within projects. We may have a lot of these function apps, we see great value in small code segments to do utility type of work, and I don't want dozens and dozens of independent repos just because of DevOps deployments. Is there a way to have a unique build and release process for each project, not the repo entirely? We aren't clear how this can be done and searches have come up empty on this. I thought it was possible to have unique build YAMLs per project across many projects in a single repo - but unclear how to implement the DevOps build and release pipleines to support this approach - ie; only a single function gets updated and we need to deploy - any guidance if this is possible and how to approach it would be great.
I haven't done this myself, but I'm in a similar situation where I'd like to have multiple functions (and other stuff) in a single Git repo for simplicity, but only build/deploy them as needed when they change. It looks like you can have multiple pipelines on a single repo with a different YAML file for each pipeline. The steps are documented in this link, and summarized below
In Azure DevOps, create a new Pipeline.
For the "Where is your code?" page, at the bottom choose the Use the classic editor option.
Select your source repo and branch.
On the "Select a template" screen, choose the YAML option at the top. Hit Apply.
There is a YAML file path field where you can specify the path and name of your YAML file for the pipeline.
You may want to set the pipeline to run manually if you don't want a build each time there's a commit to the repo.
EDIT There may be an easier way to do this now. If you go through the New Pipeline wizard, select your source location, on the Configure tab, at the bottom you can choose the Existing Azure Pipelines YAML file option. This lets you select a custom YAML file directly.
Is it possible for a pipeline to have multiple triggers in one YAML file that executes different jobs per trigger?
In our pipeline, we pack each project in the solution and push it as a nuget package in our own azure devops artifacts and want to do the packing and pushing depending on the project. Saw that it is possible to specify the branch and path in the trigger, but you can only have one trigger according to this. But he only indicated it in the question, and the documentation doesn't explicitly state it.
Right now my option is to just configure different pipelines with yaml files per project but I want to ask here to confirm if this is possible or not.
Agree with Jessehouwing You can add multiple triggers. You can use conditionals on tasks, jobs, stages and environments to only run in specific cases.
https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#triggers
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?tabs=yaml&view=azure-devops
Thanks for the input, studied the docs but it's not possible to achieve what I wanted with just the built in tasks for azure devops. I had to make a script that does it and assign true of false values to the conditionals.
The exact answer I was looking for was in this post
Suppose we have 100 static websites of similar type. It will have similar build pipeline tasks. So instead of creating build and release pipelines one by one using visual designer, is there a way to automate it so that it will get created automatically?
You can do that via rest api, also, if all the pipelines are in different repos you can use azure-pipelines.yaml in the root of the repo, it will pick it up automatically.
go to builds > edit > top right >
on the next screen you can rename it: