|
| 1 | +phases: |
| 2 | +- phase: source_build_ci |
| 3 | + variables: |
| 4 | + buildLoggingOptions: /clp:v=detailed /p:MinimalConsoleLogOutput=false |
| 5 | + buildConfiguration: Release |
| 6 | + buildOfflineTarball: false |
| 7 | + docker.runInRoot: docker run --rm -v $(rootDirectory):/root -w /root |
| 8 | + docker.runInSrc: docker run --rm -v $(Build.SourcesDirectory):/src -w /src |
| 9 | + docker.runInSourceBuild: docker run --rm -v $(rootDirectory)/sb/source-build:/src -w /src |
| 10 | + docker.runInTarball: docker run --rm -v $(rootDirectory)/sb/tarball/$(tarballName):/tb -w /tb |
| 11 | + dropDirectory: $(stagingDirectory)/drop |
| 12 | + rootDirectory: $(Build.SourcesDirectory)/.. |
| 13 | + stagingDirectory: $(rootDirectory)/sb/staging |
| 14 | + tarballName: tarball_$(Build.BuildId) |
| 15 | + |
| 16 | + queue: |
| 17 | + name: DotNet-Build |
| 18 | + demands: agent.os -equals linux |
| 19 | + timeoutInMinutes: 240 |
| 20 | + parallel: 2 |
| 21 | + matrix: |
| 22 | + centos71: |
| 23 | + imageName: microsoft/dotnet-buildtools-prereqs:centos711503_prereqs_2 |
| 24 | + rhel7-unshared: |
| 25 | + imageName: microsoft/dotnet-buildtools-prereqs:rhel7_prereqs_2 |
| 26 | + buildOfflineTarball: true |
| 27 | + |
| 28 | + steps: |
| 29 | + - template: ./.vsts.pipelines/steps/docker-cleanup-linux.yml |
| 30 | + |
| 31 | + # create working directory and copy source into it |
| 32 | + - script: | |
| 33 | + set -x |
| 34 | + $(docker.runInRoot) $(imageName) rm -rf /root/sb/ |
| 35 | + $(docker.runInRoot) $(imageName) mkdir -p /root/sb/tarball |
| 36 | + $(docker.runInSrc) -v $(rootDirectory):/root $(imageName) cp -r . /root/sb/source-build |
| 37 | + displayName: Clean sb directory and copy source from cloned directory |
| 38 | +
|
| 39 | + # fetch vsts commits if building internally |
| 40 | + - script: | |
| 41 | + set -x |
| 42 | + # Ignore failure for the first command. It will intentionally fail if the commit is only |
| 43 | + # available in VSTS. "submodule update --init" is the simplest way to set up the submodule |
| 44 | + # directory. ("submodule init" only sets up .git/config, not the e.g. src/coreclr/.git and |
| 45 | + # .git/modules/src/coreclr/ directories.) |
| 46 | + $(docker.runInSourceBuild) $(imageName) git submodule update --init --recursive |
| 47 | + $(docker.runInSourceBuild) $(imageName) ./fetch-vsts-commits.sh $(user.PAT) |
| 48 | + displayName: Fetch internal vsts commits |
| 49 | + condition: and(succeeded(), ne(variables['user.PAT'], '')) |
| 50 | +
|
| 51 | + # init submodules |
| 52 | + - script: $(docker.runInSourceBuild) $(imageName) git submodule update --init --recursive |
| 53 | + displayName: Initialize submodules |
| 54 | + |
| 55 | + # build source-build |
| 56 | + - script: $(docker.runInSourceBuild) $(imageName) ./build.sh /p:ArchiveDownloadedPackages=true /p:Configuration=$(buildConfiguration) /p:ProdConBlobFeedUrlPrefix=$(prodConBlobFeedUrlPrefix) $(buildLoggingOptions) |
| 57 | + displayName: Build source-build |
| 58 | + timeoutInMinutes: 90 |
| 59 | + |
| 60 | + # copy logs to working directory |
| 61 | + - script: | |
| 62 | + set -x |
| 63 | + $(docker.runInSourceBuild) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/source-build/binlogs; find . -name '*.binlog' -exec cp {} /logs/source-build/binlogs \;" |
| 64 | + $(docker.runInSourceBuild) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/source-build/logs; find ./bin/logs -name '*.log' -exec cp {} /logs/source-build/logs \;" |
| 65 | + displayName: Copy source-build logs |
| 66 | + condition: always() |
| 67 | + continueOnError: true |
| 68 | +
|
| 69 | + # run smoke tests |
| 70 | + - script: $(docker.runInSourceBuild) $(imageName) ./build.sh /t:RunSmokeTest /p:Configuration=$(buildConfiguration) /p:ProdConBlobFeedUrlPrefix=$(prodConBlobFeedUrlPrefix) |
| 71 | + displayName: Run smoke-test |
| 72 | + |
| 73 | + # copy smoke test logs to working directory |
| 74 | + - script: $(docker.runInSourceBuild) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/source-build/smoke-test; find ./testing-smoke -name '*.log' -exec cp {} /logs/source-build/smoke-test \;" |
| 75 | + displayName: Copy smoke-test logs |
| 76 | + condition: and(succeeded(), eq(variables['buildOfflineTarball'], false)) |
| 77 | + continueOnError: true |
| 78 | + |
| 79 | + # create tarball |
| 80 | + - script: $(docker.runInSourceBuild) -v $(rootDirectory)/sb/tarball:/tb $(imageName) ./build-source-tarball.sh /tb/$(tarballName) --skip-build |
| 81 | + displayName: Create tarball |
| 82 | + condition: and(succeeded(), eq(variables['buildOfflineTarball'], true)) |
| 83 | + |
| 84 | + # tar the tarball directory into the drop directory |
| 85 | + - script: $(docker.runInSourceBuild) -v $(rootDirectory)/sb/tarball:/tb -v $(dropDirectory):/drop $(imageName) tar -zcvf /drop/$(tarballName).tar.gz /tb/$(tarballName) |
| 86 | + displayName: Copy tarball to output |
| 87 | + condition: and(succeeded(), eq(variables['buildOfflineTarball'], true)) |
| 88 | + |
| 89 | + # build tarball |
| 90 | + - script: $(docker.runInTarball) --network='none' $(imageName) ./build.sh /p:Configuration=$(buildConfiguration) $(buildLoggingOptions) |
| 91 | + displayName: Build tarball |
| 92 | + timeoutInMinutes: 90 |
| 93 | + condition: and(succeeded(), eq(variables['buildOfflineTarball'], true)) |
| 94 | + |
| 95 | + # run smoke tests |
| 96 | + - script: $(docker.runInTarball) $(imageName) ./smoke-test.sh --minimal --projectOutput --configuration $(buildConfiguration) --prodConBlobFeedUrl '' |
| 97 | + displayName: Run smoke-test in tarball |
| 98 | + condition: and(succeeded(), eq(variables['buildOfflineTarball'], true)) |
| 99 | + |
| 100 | + # copy all tarball logs to working directory |
| 101 | + - script: | |
| 102 | + set -x |
| 103 | + $(docker.runInTarball) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/tarball/binlogs; find . -name '*.binlog' -exec cp {} /logs/tarball/binlogs \;" |
| 104 | + $(docker.runInTarball) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/tarball/logs; find ./bin/logs -name '*.log' -exec cp {} /logs/tarball/logs \;" |
| 105 | + $(docker.runInTarball) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/tarball/smoke-test; find ./testing-smoke -name '*.log' -exec cp {} /logs/tarball/smoke-test \;" |
| 106 | + # Copy prebuilt report |
| 107 | + $(docker.runInSourceBuild) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/prebuilt-report/online; cp -r ./bin/prebuilt-report/* /logs/prebuilt-report/online" |
| 108 | + $(docker.runInTarball) -v $(dropDirectory)/logs:/logs $(imageName) /bin/bash -c "mkdir -p /logs/prebuilt-report/offline; cp -r ./bin/prebuilt-report/* /logs/prebuilt-report/offline" |
| 109 | + displayName: Copy tarball logs |
| 110 | + condition: eq(variables['buildOfflineTarball'], true) |
| 111 | + continueOnError: true |
| 112 | +
|
| 113 | + # copy artifacts to staging - Copy to VSTS owned folder is done outside of docker so copied files have correct ownership so VSTS can clean them up later. |
| 114 | + - task: CopyFiles@2 |
| 115 | + condition: always() |
| 116 | + continueOnError: true |
| 117 | + inputs: |
| 118 | + sourceFolder: $(stagingDirectory) |
| 119 | + targetFolder: $(Build.ArtifactStagingDirectory) |
| 120 | + |
| 121 | + # publish artifacts |
| 122 | + - task: PublishBuildArtifacts@1 |
| 123 | + displayName: Publish artifacts |
| 124 | + condition: always() |
| 125 | + continueOnError: true |
| 126 | + inputs: |
| 127 | + PathtoPublish: $(Build.ArtifactStagingDirectory)/drop |
| 128 | + ArtifactName: drop |
| 129 | + ArtifactType: Container |
| 130 | + |
| 131 | + - template: ./.vsts.pipelines/steps/docker-cleanup-linux.yml |
0 commit comments