github action cicd pipeline for creating github release tag using semver and conventional commit - docker

I am trying to create a CICD github action pipeline that takes care of automating github releases, tags using the semver and conventional commits. It maintains a challenge log file for versioning, and tags a Docker image based on the release/tag and pushes it to gcr/gar after a successful build.

Related

Difference between lightweight checkout and shallow clone in Jenkins

In the pipeline SCM configuration of Jenkins job builder, we have two options- lightweight checkout and shallow clone. What is the difference between these options and when do we use each option?
From the documentation:
Shallow clone.
Perform a shallow clone, so that git will not download the history of the project, saving time and disk space when you just want to access the latest version of a repository.
Lightweight checkout.
If selected, try to obtain the Pipeline script contents directly from the SCM without performing a full checkout. The advantage of this mode is its efficiency; however, you will not get any changelogs or polling based on the SCM. (If you use checkout scm during the build, this will populate the changelog and initialize polling.) Also build parameters will not be substituted into SCM configuration in this mode. Only selected SCM plugins support this mode.
To sum up:
Shallow Clone is the Git feature that lets you pull down just the latest commits, not the entire repo history. So if your project has years of history, or history from thousands of commits, you can select a particular depth to pull.
Lightweight checkout is a Jenkins capability that enables to pull a specific file from the repo, as opposed to the entire repo. So it is useful for example when fetching the Jenkinsfile from a repo because you you need only the specific file and Don't care about other SCM information.

How to migrate from Jenkinsfile to pipeline_config.groovy which uses JTE?

I'm in the process of migrating git-based projects to use a shared Pipeline definition from a governance tier built with Jenkins Templating Engine.
In the process of testing I cloned the project and pushed it to a new repository in Bitbucket where it was recognized by Jenkins and the template was used immediately based on the definitions in pipeline_config.groovy. However, this is not a sane migration path for existing projects. How do I get Jenkins to start using the template on branches without Jenkinsfile and the Jenkinsfile on branches with a Jenkinsfile.
The result of of "Scan Multibranch Pipeline Now" according to the logs is ‘Jenkinsfile’ not found. Skipping. I assume that a new project regonizer is provided by the Jenkins Templating Plugin.
I assume that every project with Git Flow has to perform this migration, so I'm confused there's no documentation.
I'm using Jenkins 2.306 and JTE plugin 2.3.
It seems that newer versions of JTE or Jenkins allow a mixture of branches with JTE and without.
In case you have to deal with versions that don't do the following:
Once I removed Jenkinsfile from every branch and put a pipeline_config.groovy on every branch the Multibranch Plugin started recognizing the project first as removed and at the next scan as present with all branches which were all using the Jenkins Template Engine.
Not the best migration imo, but a great opportunity to cleanup old branches. Since my project was using Git Flow I needed to make a technical hotfix release to also migrate away from Jenkinsfile on master.

Best approach for build/release pipeline in AzDo for 2 separate projects/repos

I have 2 separate projects in AzDo, project-1 contains repo to build docker image and tag it accordingly like 1.0.0 , 1.0.1 etc. and in another projects-2 there are 2 separate repos which uses these tags. currently this is manual in repos#project-2.
My question is how can I automate the process in AzDo, that means if there is a new tag for docker in repo#project1 then it will automatically build the repos in project-2 with this new docker tag.
e.g. currently project-1 has image:1.0.0 and this is used in 2 repos in project-2 manually referring to 1.0.0.
Now I build a fresh tag in project-1 with tag 2.0.0, so how can I automatically build 2 repos#project-2 with this new 2.0.0 . Is there any link/signal from one build/release pipeline to another pipeline/project?
Any advice is greatly appreciated.
The easiest way it will be to use pipeline triggers which allow you to trigger one pipeline after another. You may have an issue fetching docket image tag but simply you may resolve this by hitting your container registry.
Please check out also stages filter, maybe they will provide a value for your case.
In this sprint, we added support for 'stages' as a filter for pipeline resources in YAML. With this filter, you don't need to wait for the entire CI pipeline to be completed to trigger your CD pipeline. You can now choose to trigger your CD pipeline upon completion of a specific stage in your CI pipeline.
Another option will be to use webhook when your image is pushed to container registry and trigger another pipeline over REST API.
According to your description, seems you are talking about two different team project.
Is there any link/signal from one build/release pipeline to another pipeline/project?
You want to trigger a pipeline in another team project.
In the classic editor, pipeline triggers are called build completion triggers. You can select any other build in the same project to be the triggering pipeline.
Thus you have to specify pipeline triggers directly within the YAML file instead of configuring build completion triggers in the UI.
# this is being defined in app-ci pipeline
resources:
pipelines:
- pipeline: securitylib # Name of the pipeline resource
source: security-lib-ci # Name of the pipeline referenced by the pipeline resource
trigger:
branches:
- releases/*
- master
To trigger a pipeline upon the completion of another, specify the triggering pipeline as a pipeline resource.
Note: If the triggering pipeline is in another Azure DevOps project, you must specify the project name using project: OtherProjectName.
More detail sample and limitation refer: https://stackoverflow.com/a/61398607/5391065
For Classic editor, you need to use some 3rd-paty extension such as this one--Trigger Azure DevOps Pipeline, it's able to select other project where the pipeline resides.

Jenkins pipline - how to access github webhook payload

Im trying to build a Jenkins pipeline which enforces gitflow.
My requirements are that when there is a merge from the release branch (e.g. release/v1.0.0) to master i will use the same docker image that was created during the last commit on the release branch, before the merge commit (in other words, use latest image that was approved in staging).
I'm trying to figure out how to access the GitHub PullRequestEvent event payload in my groovy jenkins pipeline, so i can see if the source branch is a release branch and tag the container with the release version tag. Then I'll use them in my pipeline.

How to automate creation of Tags on BitBucket from Jenkins using WebHooks?

Is there any way to to support automatic tag creation on Bitbucket via Jenkins pipeline?
I know how to build a branch a Tag is created or a push is done to the repo.
You can use the Git Publisher addon in the Post-build Actions to do this. It does a lot more than just auto pushing tags but that is what I use it for. Right now, I have it set to push the build number as a tag to the branch that is being used.

Resources