Avoid Duplicate CI Pipelines on GitLab - gitlab

Some additional stages in my CI pipeline like release-test and release are triggered if I push a tag with a specific keyword release. The problem is that the CI pipeline first runs for the branch and then repeats the first three steps for the tag push.
Is there any way to avoid this duplication and run only the tag pipeline?

while pushing the tag and the commit I was using:
git push && git push --tags
To skip the ci pipeline for the commit, I used:
git push -o ci.skip && git push --tags
This solved the problem for me with duplicate ci runs.

Related

Azure build pipeline (Power apps solution) run successfully but Artifact not displayed in Repo. but its displayed in pipeline artifact

Azure build pipeline run successfully but Artifact (folder and files) not displayed in Repo.
This is pipeline for Power apps solutions
I have mentioned the following paths for Solution export and import
Solution output file : $(Build.StagingDirectory)$(SolutionName)_Unmanaged.zip
Solution Input file : $(Build.StagingDirectory)$(SolutionName)_Unmanaged.zip
Target folder to unpack the solution : $(Build.StagingDirectory)$(SolutionName)\Unmanaged
target version : not given
I have bit doubt that these paths are created automatically
Publish to Artifact : $(Build.StagingDirectory)$(SolutionName)\Unmanaged
Build pipeline
Artifact published
Azure repo screenshot
Azure Pipeline will clone the Repo to the agent, changes are made on the agent environment and will not sync to Repo automatically.
If you want the Artifact display in Repo, you could add a PowerShell task after your build tasks in your pipeline to push the change the Target Repo:
git push https://{PAT}#dev.azure.com/{OrgName}/{ProjName}/_git/{RepoName}

How do I resolve merge conflicts using git rebase?

I want to know how I can resolve merge conflict using git rebase? I use gitlab UI to create merge request. Currently its showing "There are merge conflicts". How to get rid of this error on UI so that the administrator of project merges the "merge request" from UI?
I have new branch called "feature/one" which I am trying to merge into "dev" and ran into conflict issue.
Any help, greatly appreaciated.
If you are alone working on the feature/one, you would rebase it on top of dev locally, resolve the conflict there (meaning locally on your machine) and force push.
That is
git switch feature/one
git rebase dev
# resolve conflicts
git push --force
That would update your merge request automatically.

Go.CD - Updating git repo in build pipeline triggers another build

I am trying to update my git repo during the GoCD build. That means that because Go sees another change it triggers another build.
Is it possible to stop the re-triggering of the build?
Background:
I am building and publishing npm packages and I want to automatically increase the prerelease version so I don't have to remember it.
My pipeline looks essentially like this:
npm version prerelease --no-git-tag-version
npm publish
git add package.json
git commit -m "Bump prerelease version"
git push origin
This will update the version in git if the publish succeeds but also triggers another build since Go is polling.
Configure your CD/CI tool to build only when there is a commit to a specified branch or you can probably create a new branch called "pre-release" and configure CD/CI not to build when there is a commit.
Once this configuration is done in the CD/CI tool
npm version prerelease --no-git-tag-version
npm publish
// fetching for other branches
git fetch
// Switching your branch
git checkout pre-release
// Finally committing
git add -m "Your commit message"
git push -u origin pre-release
I hope this works out for you :)
You can configure your stages in your pipeline to be triggered manually, for example, if you where setting up your pipelines as code, in your ${pipeline_name}.gocd.yaml.
- deploy-to-next-stage:
approval: manual <-- You need this!
jobs:
deploy:
tasks:
...
This may help as you could run an automated deploy to a development stage and then manually push successful builds to the next stage (pre-release perhaps). In this way, your builds that worked would not be effected by new builds being triggered by a push to your repo.
Or you could put this on your first stage and your entire pipeline would not be triggered by the push to the repo, but instead by you heading into the GUI and triggering it yourself.

`git clone project2` in gitlab-ci.yml?

I'd like Gitlab CI to fetch source code of another project. Is there a better way than adding a read-only deploy key and setting it up in .gitlab-ci.yml?
You can also use GIT SUBMODULES within your project A to refer to project B and then add
GIT_SUBMODULE_STRATEGY: recursive
to the gitlab-ci.yml file in project A.
This also enables you to specifically include a specific branch or commit from your subproject.
https://docs.gitlab.com/ce/ci/git_submodules.html

How to "resync" commits in GitLab after fetching from remote repository?

I've created GitLab project by cloning remote repository. During a few days my colleagues pushed their commits to the original repository (not GitLab). Now I did 'git fetch --all' from GitLab repository but commits do not show in GitLab web UI. What should I do to resync GitLab project with its repository? Is there rake task for that? I can't simply recreate the project as we already imported issues from an external source, created labels, milestones, etc.
There is no GitLab feature to fetch the upstream updates. What you did was import an already existing repository, and that is a one time feature.
But you can fetch the upstream updates into your local repository, then push them to GitLab. You'll need to add the orginial/upstream repo as a remote to your local repository by running git remote add upstream {path to original repo}, then fetch the upstream repos by running git fetch upstream, then merge git merge upstream/master, then git push master origin.
GitHub has a decent help section on adding the upstream remote, and doing the merge.
Only the EE version of GitLab has the repository mirroring feature which supports automatically pulling down updates from the import source repository.
If you are using the free CE version, you'll have to manually update or create a custom process.

Resources