How to deploy base on multiple branch? - deployment

I am using appveyor to publish packages to nuget, I would like to do the publish if the branch is either master or dev, my current settings is
deploy:
provider: NuGet
on:
branch: master
How can I add dev branch?

I solved this problem by using regex, here is what i got
on:
branch: /^(master|dev)$/

Related

is there any way to select branches from multiple repositories in CI build

I have trigger in azure-pipelines.yaml like below.
resources:
repositories:
- repository: APPLICATION
type: git
name: AAA/APPLICATION
ref: master
- repository: TESTS
type: git
name: AAA/TESTS
ref: master
STAGES:
- stage : BuildApplication
// checkout branch & build necessary things
- stage : BuildTests
// checkout branch & build necessary things
Since the yaml resides in Application repository, While creating manual CI build I am able to select the Branches in Application repository & for Tests repository the branch checkout will be master always.
is there any was I can able to set the branch details of Tests repository before creating release ?
Is there any was I can able to set the branch details of Tests repository before creating release ?
From your YAML sample, you need to select the Resource Repo branch when manually running the pipeline.
I am afraid that there is no out-of-box method can select the resource repo branch. The branch is defined at resources field. When you running the pipeline, it will use the default branch.
For a workaround, you can change to define the repo in check out field. You can use paramter to define the repo branches and then you can select the branch when you running the pipeline.
Refer to this doc: Inline syntax checkout
Here is an example:
parameters:
- name: test
values:
- refs/heads/main
- refs/heads/test1
pool:
vmImage: ubuntu-latest
steps:
- checkout: git://azure/Repo13#${{ parameters.test }}
Result:

Triggering an Azure pipeline from a repository in a different organization

I'm trying to set up a pipeline that will trigger, when a commit is made in a repository that exists in a different organization.
In my own org, I've created a git repo with a yaml pipeline file in the main branch.
With the below setup, I can checkout the code from the other organization if I run the pipeline manually. But it is not triggered when a commit is pushed to that repository.
Looking at the documentation, this should be possible?
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers
resources:
repositories:
- repository: OtherOrgRepo # In a different organization
endpoint: OtherOrgConnection
type: git
name: proj/reponame
ref: develop
trigger:
- develop
pool:
vmImage: ubuntu-latest
steps:
- checkout: OtherOrgRepo
The token used for the service connection has full access.
Is this not supported, or am I missing a step?
I guess I just need to read the big blue box:
https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers
Repository resource triggers only work for Azure Repos Git repositories in the same organization at present. They do not work for GitHub or Bitbucket repository resources.
I did however manage to trigger a classic pipeline by using a generic Git service connection, which will poll for changes at an interval.

Backup all github repo to bitbucket

similar question: Auto mirror all GitHub repository to gitlab
GitLab supports a pull mirror, which makes backup from github to gitlab much easier.
does bitbucket support mirror also?
if not, is "using a server to push changes" the only way to backup all repo from github?
does bitbucket support mirror also
No pull mirror that I know of, only smart mirror (to mirror remote repositories locally)
if not, is "using a server to push changes" the only way to backup all repo from github?
Yes, except it would be the GitHub servers, not your own.
You could use actions/mirroring-repository:
A GitHub Action for mirroring a repository to another repository on GitHub, GitLab, BitBucket, AWS CodeCommit, etc.
This will copy all commits, branches and tags.
Example, from pixta-dev/repository-mirroring-action issue 3
# Deploy to BitBucket repos
name: Deploy to BitBucket Wordpress Repositories
# You may pin to the exact commit or the version.
# uses: pixta-dev/repository-mirroring-action#02f1627ade9e6b3b69e6a6d4fe8bc997474f48d1
# uses: pixta-dev/repository-mirroring-action#v1
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
deploy_to_test_repo:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout#v1
- uses: pixta-dev/repository-mirroring-action#v1
with:
target_repo_url:
git#bitbucket.org:username/reponame.git
ssh_private_key:
${{ secrets.BITBUCKET_SSH_PRIVATE_KEY }}
Except you would need to use an access key.

Errors on using git commands in Azure pipelines

I am working on an Azure pipeline for a dotnet core project that runs on Windows Self hosted agent.
I want my pipeline to use Git commands to check out the release branch and merge the develop branch into it. Next steps will be to build the release branch and deploy to intranet servers
I don’t know Git wording very good, I was using TFS for years. I use the commands below and got the logs here:
- task: CmdLine#2
displayName: Checkout Release branch
inputs:
script: |
#echo off
git checkout release
git pull develop
git status
From the logs, I understand:
It downloads the content of the develop branch because it is the default branch in GitHub, I’d rather want the release branch but I believe Azure is like that
I manage to switch to release but I have these errors that I don’t understand:
##[error]Previous HEAD position was bc94bd2 Update Staging Build Pipeline.yml
##[error]Switched to branch 'release'
I understood that pull can be used with local or remote branch so I use it to fetch and merge the develop branch to the release branch but I get: [error]fatal: 'develop' does not appear to be a git repository
Do I have to specify credentials on every calls to git?
On the last step, it fetches again the code from the develop branch and I understand why
If you could help me improve my script, that would be great,
Many thanks.
You can use git merge commands to merge branches. To merge develop branch into release branch you can use git merge origin/develop. Check the document for more information. See below example:
steps:
- checkout: self
persistCredentials: true
- task: cmdLine#2
inputs:
script: |
#echo off
git checkout release
git merge origin/develop
git status
However, it is not recommended to deploy release branch in above way. You can change the default branch of your azure pipeline to release branch and enabled the Continuous Integration trigger for release branch.
So that you can create a pull request to merge develop into release from the github UI or by using commands. After develop is merged into release, the azure pipeline will be automatically triggered to deploy from release branch. Note: the azure pipeline yaml file must exist in release branch too. See below steps:
1, To change azure pipeline branch from develop to release:
On your azure devops pipeline Edit page, Click the 3dots and click Triggers
Go to YAML tab--> Get Sources-->Click the 3dots to change the default branch.
2, Set CI trigger for release branch
In the azure pipeline yaml file, set the trigger to include release branch(You can also set PR trigger):
(Actually you do not need to follow above steps to change the default branch. You just need to include the azure pipeline yaml file in release branch and set the CI trigger to include release branch as below)
trigger:
branches:
include:
- release
exclude:
- develop #if you want disable CI trigger for develop branch
By adding the CI trigger to include the release branch in the azure pipeline yaml file. Azure pipeline will automatically be triggered on release branch when merging from develop into release branch.

Skipping deployment with the npm provider because this branch is not permitted to deploy

I am trying to build and deploy my npm package to npm registry automatically upon push to master branch.
Here is my .travis.yml file content:
language: node_js
node_js:
- '0.11'
- '0.10'
deploy:
provider: npm
api_key:
secure: XXX
on:
tags: true
branch: master
The build runs successfully, but the deployment fails with message:
Skipping deployment with the npm provider because this branch is not permitted to deploy.
Why is that? I tried both without specifying any branch and specifying 'master' branch explicitly.
Here is the travis build status in details.
Any suggestion/clue to solve this issue is appreciated. Thanks in advance.
With tags: true you specify, that only tagged commits will be deployed. If I'm not mistaken, Travis CI does not explicitly check on which branch such a commit is on. So either specify tags: true, then make a tagged commit OR specify branch: master and commit to this branch to trigger a deployment.
But using both statements won't work.
You can find a note in the Travis CI documentation (similar for GitHub) stating:
tags: When set to true, the application is deployed when a tag is applied to the commit. (Due to a known issue, you should also set all_branches: true.)
So the correct answer is to specify either a branch OR use tags: true and all_branches: true.
If you're using GitHub:
Please note that deploying GitHub Releases works only for tags, not for branches.