Azure DevOps: release version - azure

I am going to create my CI/CD pipeline in Azure DevOps, but I have a problem with release version number. with this CI/CD a dotnet app build and a docker image created, so I want to have docker image release number same as : V1.2.0 and ..... but currently I have number for example: 10, 11, ... or only the latest tag!
Can anybody support me to have my own release version number ?
Thanks

You could set the release version number in Release Pipelines -> Options -> General -> Release name format.
The $(rev:r) is an incrementing variable. So you could add it in the Release version.
For example: V1.2.$(rev:r)
Result:
Note: the $(rev:r) counts from 1 (1,2,3...).
From your requirement, you are using CI and CD process and it seems that you need to count from 0. You also could try to use the $(Build.buildnumber) variable.
Here are the steps:
Step1: In Build Pipeline(CI) , set the count variable(e.g. BuildRevision :$[counter( ' ',0)]).
Step2: Use the variable in Build number (Build Pipeline->Options ->Build number format).
Step3: Set the build artifacts as the release source. Use the $(Build.buildnumber) in release pipeline version.
Result:
In this situation, the release version could start from v1.2.0.
Update:
when I change the release version for example from V0.0 to V1.0 , how the counter restarted ?
You could try the following steps:
Create 2 variables:
1.major-minor = 0.0
2.revision = $[ counter(variables['major-minor'],0) ]
The build number: $(major-minor).$(revision)
In this case, when the major-minor change as V1.0, the counter will reset.

In that case you can use GitVersion and Semantic Versioning pattern.
For that you will need this extension: https://marketplace.visualstudio.com/items?itemName=gittools.gitversion
After that you add the step before compiling/build your project:
steps:
- task: GitVersion#5
inputs:
runtime: 'core'
After that you can use variable:
$(GitVersion.FullSemVer)
That variable will store the current build version - it's based on git.

Related

What is the "release" stage in gitlab-ci good for?

Can someone explain to me in simple terms what the release stage actually does, and why that is useful?
As for as I understand the official documentation, all it does is create some kind of tag?!
EDIT: (responding to wedm)
I am referring to the stage described on the official gitlab documentation on https://docs.gitlab.com/ee/ci/yaml/#release
This page describes all the details, but I don't get the big picture: Why are we doing this, what are we trying to accomplish here?
I have taken over a project that has a "release" stage after the deploy stage:
release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- build-release-env
rules:
- if: "$CI_COMMIT_TAG =~ /^v/"
variables:
ASSET_URL_BUILD: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_SHA}/download?job=build-www"
ASSET_URL_BUNDLE: "${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_SHA}/download?job=docker-image"
script:
- echo "Creating release for ${CI_COMMIT_TAG} (${CI_COMMIT_SHA})"
- cat ./CHANGELOG.latest.md
- |
release-cli create --name "Release ${CI_COMMIT_TAG}" --tag-name ${CI_COMMIT_TAG} \
--description ./CHANGELOG.latest.md \
--assets-link "{\"name\":\"Complete Build\",\"url\":\"${ASSET_URL_BUILD}\"}" \
--assets-link "{\"name\":\"Docker image\",\"url\":\"${ASSET_URL_BUNDLE}\"}" \
--ref ${CI_COMMIT_SHA}
Quoted from the GitLab documentation about releases (emphasis mine):
To introduce a checkpoint in your source code history, you can assign a Git tag at the moment of release. However, in most cases, your users need more than just the raw source code. They need compiled objects or other assets output by your CI/CD system.
One common example would be to attach built binaries to a release.
Concerning your given example: from the script part it looks like it's creating a gitlab release for the project it's run on. Doing that programmatically gives some advantages, as not all options (e.g. timed releases) are available via the web ui of gitlab.

Azure Devops path for Power Platform CD

I'm Trying to setup a Release CD for D365 (or Power Platform) using the "Power Platform Deploy Package" task:
https://learn.microsoft.com/en-us/power-platform/alm/devops-build-tool-tasks
I can see the build and release are flowing correct except for the very last part.
I can tell it works all the way to the "Download Artifact" part "
Download Artifact
Do I need anything else beside those 2?:
pipeline
I get this "Package File not specified or not found" error:
error
same error with several combinations of env variable paths. tried the exact path and still does not work
Am I forgetting anything?
path
The code is produced with the VS CRM Package and compiled just fine. I only updated the .net framework version to 4.7.2.
vs template
If you are using Hosted agent instead of Self-hosted agent, we need to specify the path using predefined variables $(Build.ArtifactStagingDirectory) instead of D:\a\r1\a, then it should be work.
Also we could add the task Copy files to filter the .dll file and copy them to another path, then specify the Package File path.
Note: I just share the yaml sample, you could enter the variable to class edit mode(UI)
- task: CopyFiles#2
displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
inputs:
Contents: |
$(Build.ArtifactStagingDirectory)/_Demo-CI/drop/bin/Debug/*.dll
TargetFolder: '$(Build.ArtifactStagingDirectory)'

Error performing git clone from azure devops pipeline task

I have a problem executing a pipeline in azure devops.
This task is part of my pipeline, as you can see it is an instruction to clone a repository.
- script: |
mkdir FOLDER_PUBLISH_AZURE
git clone https://$(AZURE_DEPLOY_USERNAME):$env:MY_AZURE_DEPLOY_PASSWORD#develroomlabs-events.scm.azurewebsites.net:443/develroomlabs-events.git FOLDER_PUBLISH_AZURE
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Download SCM repo for pipeline '
env:
MY_AZURE_DEPLOY_PASSWORD: $(AZURE_DEPLOY_PASSWORD)
The result I get is as follows:
But the pipeline variables are well added, I did a test by directly adding username and password in the YAML file, but the result was the same.
What could be happening? Am I doing something wrong?
I do this same task of cloning a repository from a bitbucket pipeline and I have no problems.
Try doing that in Windows environment with Microsoft-hosted windows agents instead of Micorosft-hosted Linux agents.
I can reproduce same issue when using Linux environment, but it actually works well in windows environment. I think this issue could be related to that Linux has different behavior when treating url format like https://$AppName:xxx#sAppName.scm.azurewebsites.net:443/AppName.git...
(Something looks like this ticket,the behavior should have something to do with Linux server itself)

Unable to run Azure pipeline "A task is missing. The pipeline references a task called 'Cache'

I am setting up my fork of a Github project with the azure_pipeline.yaml configuration.
This seems to work just fine for everyone else in the community but when I setup the pipeline it gives me the following exception:
A task is missing. The pipeline references a task called 'Cache'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com. (Task version 2, job 'compile_ci_build', step ''.)
A task is missing. The pipeline references a task called 'Cache'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com. (Task version 2, job 'test_ci_build', step ''.)
A task is missing. The pipeline references a task called 'Cache'. This usually indicates the task isn't installed, and you may be able to install it from the Marketplace: https://marketplace.visualstudio.com. (Task version 2, job 'e2e_ci_build', step ''.)
Specifically,
Here is my Azure pipeline link
I am creating Flink CI build pipeline according to this instruction.
Which already have an azure-pipeline.yml in the repo
It uses the template to run the job parameterized in tools/azure-pipelines/jobs-template.yml
[UPDATE]
I modified the jobs-templates.yml and commented out all steps with Cache#2 and it runs fine.
Was able to get this working eventually.
Apparently for my Azure account. I am not allow to use Cache#2.
changing all lines with
- task: Cache#2
to
- task: CacheBeta#1
resolves all my problem.
By design, Azure DevOps does not automatically make all tasks available when you run a pipeline.
You have to add them manually as part of the pipeline.
'cache' is one such task.
I'm doing this in classic gui (non-yaml) mode as I find it easier to search for things
But what you do is in your pipeline add a new task and in the task search box type 'cache'.
This will bring up the task.
Click Add to include it in the pipeline.
For more information on this I would recommend reading:
https://learn.microsoft.com/en-us/azure/devops/pipelines/release/caching?view=azure-devops
I do not see you added cache task in your pipeline from your git repo.
It should look like the example here:
variables:
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
steps:
- task: Cache#2
inputs:
key: 'yarn | "$(Agent.OS)" | yarn.lock'
restoreKeys: |
yarn | "$(Agent.OS)"
yarn
path: $(YARN_CACHE_FOLDER)
displayName: Cache Yarn packages
- script: yarn --frozen-lockfile
Source
I was getting the same error A task is missing. The pipeline references a.. on one of azure task, PublishCucumberReport#1 . I resolved it by visiting https://marketplace.visualstudio.com/ and going to the task and then clicking on get free button, which installs it on your pipeline

Concourse: Use a semver resource to control which artifact to use from s3

My pipeline contains a task with the following pre-requisites
- get: version
trigger: true
params: { bump: patch }
passed: ["trigger_job [CI]"]
- get: sdk-package
passed: ["package_generation_job"]
params:
version: {path: "artifact_[I want to put the version here]"}
version is a semver stored in git; sdk-package is a build artifact stored in s3 where each run of the pipeline puts a new artifact using the version number as part of the name.
What I would like to do is used the version input to determine which version of the artifact is pulled from S3. Based on this I suspect that Concourse doesn't allow this, but I couldn't find a definitive answer.
This is not currently possible, you will have to download the artifact you want in a task script. You can pass the version into that task.

Resources