I'm trying to do something I thought was super simple... I want to grab generated files (not built) and copy them to an Azure Blob storage
In my Build the last step of my azure-pipeline.yml look like this:
- task: CopyFiles#2
displayName: 'Copy generated content'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/output'
contents: '**\*'
targetFolder: $(System.DefaultWorkingDirectory)/$(Release.PrimaryArtifactSourceAlias)/drop
cleanTargetFolder: true
Then, in the Release I have an Azure CLI step with the inline following code:
az storage blob upload-batch -s "$(System.DefaultWorkingDirectory)/$(Release.PrimaryArtifactSourceAlias)" -d '$web' --account-name frankdemo--account-key '_MYKEY_'
I try different combinations of paths, but nothing works...
Q: What should I put as targetFolder in my build and "-s" in my release?
You will need to add step so it will publish artifacts
steps:
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: Server'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
ArtifactName: Server
Then in your release you can use "Azure File Copy" to copy from your release to blob storatge
Related
I have read here: https://www.jfe.cloud/control-pipeline-artifacts-with-artifactignore-file/
that I have to copy my .artifactignore to the location where my artifact will be saved.
However, currently my Publish Artifact task isn't allowing me to set a location. It just says Azure Pipelines. What is the path for this Azure Pipelines?
I cannot use set a location as my agent is running Linux..
This is my current yaml for my Azure Pipelines
steps:
- task: CopyFiles#2
displayName: 'Copy .artifactignore'
inputs:
Contents: '**/.artifactignore'
TargetFolder: '$(Pipeline.Workspace)'
OverWrite: true
- task: PublishBuildArtifacts#1
displayName: 'Publish Artifact: sdr_core'
inputs:
PathtoPublish: '$(Agent.WorkFolder)'
ArtifactName: 'sdr_core'
EDIT:
Attached the PublishBuildArtifact screenshot. I cannot select a publish location:
I want to create two debian installers (packageName1 & packageName2) in same repo of azure-pipeline with same feed. Below is the task of my azure-pipeline.yaml file
- task: PublishBuildArtifacts#1
displayName: 'Publish artifacts'
inputs:
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: 'Installer package and anti-virus scan results'
- task: UniversalPackages#0
displayName: Publish univeral package-1
inputs:
command: publish
publishDirectory: '$(Build.ArtifactStagingDirectory)'
vstsFeedPublish: '$(packageFeed)'
vstsFeedPackagePublish: '$(packageName1)'
packagePublishDescription: ''
versionOption: custom
versionPublish: $(packageVersion1)
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- task: UniversalPackages#0
displayName: Publish univeral package-2
inputs:
command: publish
publishDirectory: '$(Build.ArtifactStagingDirectory)'
vstsFeedPublish: '$(packageFeed)'
vstsFeedPackagePublish: '$(packageName2)'
packagePublishDescription: ''
versionOption: custom
versionPublish: $(packageVersion2)
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
But when I am downloading artifact for one of the package installer through az command:
az artifacts universal download \
--organization "https://myplatform.visualstudio.com/" \
--feed "my-feed" \
--name $packageName1 \
--version $packageVersion1 \
--path .
the packages and files of packageName2 are also getting downloaded. I feel that's because I am using same Build.ArtifactStagingDirectory location to store/publish the artifacts for both packages. Can I use different location for both installer packages ?
You can create a subfolder under Build.ArtifactStagingDirectory for each project and publish each artifact separately.
There aren't 'multiple artifact directories', but you can create as many folders under the directory as you want and then pass the subfolder into the build and publish tasks.
I need this scenario to be accomplish
Jenkins is the main ci/cd tool now we want to use Azure to be our build server but only for the build that is:
Jenkins checkout source
Run some build-in scripts to prepare for build
Send source which previously check out to the build server <-- this is where the AZURE part steps in
Copy the created artifacts back to Jenkins slave
Continue with CD on Jenkins slave
How do i combine the section 3 ?
How do i combine the section 3 ?
As far as I know, you can use Azure Devops self-hosted agent to connect azure devops and Jenkins.
You can refer to the following steps:
Create an Azure Devops Self-hosted agent on the Jenkins server.
Since the Checkout Step is on Jenkins, you could add Copy file task in Azure Devops to copy the Source to the Build Directory.
e.g. Source Repo Path -> $(Build.SourcesDirectory)
After the build step, you can copy the files back to the jenkins slave path.
e.g. Source: $(build.artifactstagingdirectory) -> Target: Slave Path
If your need to copy file to another remote machine, you could try to use Copy files over SSH or Windows Machine File Copy task.
Update:
After you configure the source, you could publish the repo as artifacts in Jenkins Server.
You could use the Jenkins download artifacts task in azure devops to download the artifacts.
Note: The artifacts will be downloaded to $(Build.ArtifactStagingDirectory).
Then you could run the task and publish the build artifacts on Hosted Macos Agent.
To Copy the created artifacts back to Jenkins:
You could add another Agent job and use the self-hosted agent(On linux AWS) to download the artifacts to jenkins server.
Agent Job 1 is running on Hosted MacOs agent. Agent Job 2 is ruuning on Self-hosted agent.
Update2:
Yaml Sample:
stages:
- stage: CopyFile
pool:
name: default
jobs:
- job: testjob
steps:
- task: CopyFiles#2
inputs:
SourceFolder: 'Local Path'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Source'
publishLocation: 'Container'
- stage: BuildProject
dependsOn: CopyFile
pool:
vmImage: ubuntu-16.04
jobs:
- job: buildjob
steps:
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Source'
downloadPath: '$(System.ArtifactsDirectory)'
- task: xxx(build task)
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Artifacts'
publishLocation: 'Container'
- stage: BackToJenkins
dependsOn: BuildProject
pool:
name: default
jobs:
- job: Sendjob
steps:
- task: DownloadBuildArtifacts#0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'Artifacts'
downloadPath: '$(System.ArtifactsDirectory)'
You need to modify the path(Publish Path, Download Path) to meet your needs.
I have a publish task in Azure Devops pipeline which should publish an excel file with extension .xlsx .
am using this below command but its not working. can someone help me with the wildcards?
this excel file is dynamic and date,month parameters keeps on changing.
format: SonarQube Issue Extract_2020-08-04.xlsx
task: PublishBuildArtifacts#1
inputs:
PathtoPublish: 'C:\Users\320066547\agent\_work\3\s\SonarFetchIssues\target\*.xlsx'
ArtifactName: 'IssuesOutput'
publishLocation: 'Container'
If using a YAML pipeline look at using the PublishPipelineArtifact task
- task: PublishPipelineArtifact#1
displayName: 'Publish Artifact: drop'
inputs:
artifact: drop
targetPath: $(Build.ArtifactStagingDirectory)
This will publish all the artifacts in the pipeline. From there can narrow down the exact path that is being published.
Alternatively too can do run a Powershell task before your publish to see exactly what your folder structure looks like on the agent:
-powershell: Get-ChildItem -Path 'Insert root path' -recurse
This is clearly stated in the task:
Path to publish: The folder or file path to publish. This can be a
fully-qualified path or a path relative to the root of the repository.
Wildcards are not supported. Variables are supported. Example: $(Build.ArtifactStagingDirectory)
I'm trying to deploy a .NET application using an Azure DevOps pipeline by making use of an ARM template and storing the template in an Azure git repository.
##################yml file for the pipeline build####################
- task: DotNetCoreCLI#2
inputs:
command: 'build'
projects: '**\*.csproj'
arguments: '-c Release'
- task: DotNetCoreCLI#2
inputs:
command: 'publish'
publishWebProjects: true
arguments: '-o $(Build.ArtifactStagingDirectory)/web'
- task: CopyFiles#2
inputs:
sourceFolder: 'appdeploy/'
TargetFolder: '$(Build.ArtifactStagingDirectory)/appdeploy'
- task: PublishBuildArtifacts#1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'drop'
I am getting an error in the build step of the pipeline saying:
DotNetCoreCLI: If you're using Publish command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory.
##[error]Project file(s) matching the specified pattern were not found.
According to the error message , this issue exists in the “build” step.
You need to define in the build task which .csproj files you want to build.
In your case, the definition path projects: '**\*.csproj' has some issues.
You could use the projects: '**/*.csproj’ to replace it.
Note: The cause of this issue is the backslash.
Hope this helps.