Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy built artifacts in container uploads both checked out projects instead of right one #586

Open
msdansau opened this issue Mar 23, 2023 · 2 comments

Comments

@msdansau
Copy link

msdansau commented Mar 23, 2023

got this successful build pipeline which just compile 2 projects from diferent repos ( the first one from GH and the another from current master devops repo) all is fine but at the end the fist one deploy built artifcat (compiled project) right in the container, however the second checkout deploy the built artifact but the previous one as well. why? i tried diferent approaches without luck...

In below YAML what it does is the folllowing:
-compile and deploy built artifact from the repo of GH
-And then compile and deploy the built artifact from the repo of master in devops.

*****All works well but when I see the 2 separates built artifacts containers the first one is fine which contain the built artifact for GH , but the second Artifact container contain both projects ( both built artifacts) would you know why? I added clean=true to each check out but remains the same… I also tried to add the solution path but it doesn´t find it.

YAML file

trigger:

  • none

resources:
repositories:
- repository: testcheckout
type: github
endpoint: github.com_msdansau
name: msdansau/testcheckout
- repository: checkout_toGH_repo
type: git
name: checkout_toGH_repo/checkout_toGH_repo

ref: main

trigger: none

pool:
vmImage: 'windows-latest'

variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'

steps:

  • task: NuGetToolInstaller@1
    - checkout: testcheckout
    clean: true

  • task: NuGetCommand@2
    inputs:
    restoreSolution: '$(solution)'

  • task: VSBuild@1
    inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebAppGH.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

  • task: VSTest@2
    inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

  • script: echo "Uploading Artifact of remote github project"
    displayName: Printing a message.... "NEXT TASK IS TO UPLOAD ARTIFACT OF HITHUB REPO HERE*......."

  • task: PublishBuildArtifacts@1
    inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'GHartifact1'
    publishLocation: 'Container'

  • script: echo "CHECKOUT DEVOPS REPO NOW..."
    displayName: Printing a message.... "CHECKOUT DEVOPS REPO.............."

  • checkout: checkout_toGH_repo
    clean: true

persistCredentials: true

path: checkout_toGH_repo

  • task: NuGetCommand@2
    inputs:
    restoreSolution: '$(solution)'

  • task: VSBuild@1
    inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebAppdevops.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

  • task: VSTest@2
    inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

  • task: PublishBuildArtifacts@1
    inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'DEVOPSaRTIFACT2'
    publishLocation: 'Container'

alls works well
image

image

But it uploads both built artifacts for both repos into the last one .
The first one upload the built artifact well. Why ?

I added the clean = true to each checkout

image

the first check out uploads the right built artifact to container
image

Goal :
The only artifact that should upload to DevopsARTIFACTS2 IS webapplication1. ( not included with the previous built artifact which was for GHartifact1 (webapplication2).).

image

Any pointers would be much appreciated
In case anyone would like for me to add you as contributor to my devops project let me know.
we need to each built artifacts only deploy the right project not both on the same.

@msdansau
Copy link
Author

i have found a workaround in adding a remove artifactStagingDirectory for each new checkout so that it first clear all directory using the same job.

  • script: rm -rf $(build.artifactStagingDirectory)/*
    displayName: "Removing files from artifact staging directory"
    condition: succeeded()

if you found a better workaround for using one job for many checkouts and upload each deployed artifact it`s corresponding built artifact accordingly , please detail here the steps. thanks.

@ivanduplenskikh
Copy link

Hi @msdansau thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants