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

Fix Build failure #24

Merged
merged 14 commits into from Mar 25, 2019
6 changes: 3 additions & 3 deletions .vsts-ci/ci.yml
Expand Up @@ -3,12 +3,12 @@ resources:
- repo: self
clean: true

phases:
jobs:

- phase: Set_Build_Name
- job: Set_Build_Name
# displayName: Set Build Name
condition: ne(variables['Build.Reason'], 'PullRequest')
queue:
pool:
name: Hosted Ubuntu 1604
steps:
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhss"))"
Expand Down
30 changes: 17 additions & 13 deletions .vsts-ci/phase.yml
Expand Up @@ -2,19 +2,18 @@ parameters:
queue: 'Hosted Ubuntu 1604'
snapChannel: 'stable'

phases:
- phase: ${{ parameters.SnapChannel }}
jobs:
- job: ${{ parameters.SnapChannel }}
displayName: ${{ parameters.SnapChannel }}

queue:
name: ${{ parameters.queue }}
pool: ${{ parameters.queue }}

variables:
SnapChannel: ${{ parameters.SnapChannel }}

steps:

- powershell: 'dir env:'
- powershell: 'dir env:'
displayName: 'Capture Environment'

- powershell: |
Expand All @@ -32,12 +31,24 @@ phases:
}
}
./tools/releaseBuild/vstsbuild.ps1 -Name $buildName
$snap = Get-ChildItem "$env:AGENT_TEMPDIRECTORY/*.snap" -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty fullname -ErrorAction SilentlyContinue
if(!$snap)
{
throw "snap build failed"
}
else
{
$message = "vso[task.setvariable variable=PS_SNAP_PATH;]$snap"
Write-Host $message
Write-Host "##$message"
}
displayName: 'Build $(SnapChannel)'
condition: succeeded()
continueOnError: true

- powershell: |
$downloadUrl = Invoke-RestMethod -Headers @{'X-Ubuntu-Series'='16'} -Uri 'https://api.snapcraft.io/api/v1/snaps/details/core' | Select-Object -ExpandProperty download_url
Write-Verbose "downloadUrl: $downloadUrl" -verbose
Invoke-WebRequest -Uri $downloadUrl -OutFile ./core.snap
sudo mkdir /snap/core
sudo unsquashfs -d /snap/core/current ./core.snap
Expand All @@ -46,13 +57,6 @@ phases:
condition: succeeded()

- powershell: |
$snap = Get-ChildItem "$env:AGENT_TEMPDIRECTORY/*.snap" -Recurse -ErrorAction SilentlyContinue | Select-Object -ExpandProperty fullname -ErrorAction SilentlyContinue
Write-Host "snap- $snap"
Write-Host "##vso[task.setvariable variable=PS_SNAP_PATH;]$snap"
displayName: 'Find Snap'
condition: succeeded()

- powershell: |
sudo mkdir "/snap/powershell"
sudo unsquashfs -d "/snap/powershell/current" $(PS_SNAP_PATH)
displayName: 'Install $(SnapChannel) snap'
Expand All @@ -79,5 +83,5 @@ phases:
Write-Host "##vso[artifact.upload containerfolder=artifacts;artifactname=artifacts]$_"
}
displayName: Publish Artifacts
condition: ne(variables['Build.Reason'], 'PullRequest')
condition: succeeded()
continueOnError: true
5 changes: 3 additions & 2 deletions preview/snap/snapcraft.yaml
Expand Up @@ -4,6 +4,7 @@ icon: assets/icon.png

# the version number is not used, but required
version: 6.0.1
base: core
version-script: |
file="./version.txt"
if [ -f "$file" ]
Expand Down Expand Up @@ -37,7 +38,7 @@ parts:
filesets:
wrapper: [bin/powershell-wrapper]
stage: [$wrapper]
snap: [$wrapper]
prime: [$wrapper]
powershell-preview:
after: [launchers]
plugin: nil
Expand All @@ -63,7 +64,7 @@ parts:
thirdPartyNoticeFile="$SNAPCRAFT_PART_INSTALL/thirdPartyNotices.txt"
echo "building third party notices file - $thirdPartyNoticeFile"
cat thirdPartyNoticeHeader.txt > $thirdPartyNoticeFile
find $SNAPCRAFT_PART_INSTALL -type f -name 'copyright' -print | while read filename; do
find $SNAPCRAFT_PART_INSTALL -type f -name 'copyright' -print | while read filename; do
libname=$(dirname $filename | sed 's,^\(.*/\)\?\([^/]*\),\2,')
echo ''
echo '---------------------------------------------'
Expand Down
5 changes: 3 additions & 2 deletions stable/snap/snapcraft.yaml
Expand Up @@ -4,6 +4,7 @@ icon: assets/icon.png

# the version number is not used, but required
version: 6.0.1
base: core
version-script: |
file="./version.txt"
if [ -f "$file" ]
Expand Down Expand Up @@ -37,7 +38,7 @@ parts:
filesets:
wrapper: [bin/powershell-wrapper]
stage: [$wrapper]
snap: [$wrapper]
prime: [$wrapper]
powershell:
after: [launchers]
plugin: nil
Expand All @@ -63,7 +64,7 @@ parts:
thirdPartyNoticeFile="$SNAPCRAFT_PART_INSTALL/thirdPartyNotices.txt"
echo "building third party notices file - $thirdPartyNoticeFile"
cat thirdPartyNoticeHeader.txt > $thirdPartyNoticeFile
find $SNAPCRAFT_PART_INSTALL -type f -name 'copyright' -print | while read filename; do
find $SNAPCRAFT_PART_INSTALL -type f -name 'copyright' -print | while read filename; do
libname=$(dirname $filename | sed 's,^\(.*/\)\?\([^/]*\),\2,')
echo ''
echo '---------------------------------------------'
Expand Down
12 changes: 12 additions & 0 deletions tools/releaseBuild/Images/GenericLinuxFiles/snapcraft-wrapper
@@ -0,0 +1,12 @@
#!/bin/sh
SNAP="/snap/snapcraft/current"
SNAP_NAME="$(awk '/^name:/{print $2}' $SNAP/meta/snap.yaml)"
SNAP_VERSION="$(awk '/^version:/{print $2}' $SNAP/meta/snap.yaml)"
SNAP_ARCH="amd64"

export SNAP
export SNAP_NAME
export SNAP_VERSION
export SNAP_ARCH

exec "$SNAP/usr/bin/python3" "$SNAP/bin/snapcraft" "$@"
@@ -1,33 +1,33 @@
# Docker image file that describes an Ubuntu16.04 image with PowerShell and SnapCraft installed from Microsoft APT Repo
FROM snapcore/snapcraft:stable
FROM mcr.microsoft.com/powershell:ubuntu-16.04

# Install apt-utils (for apt-key used later)
# Install ca-certificates so we can use ssl
ARG SNAPCRAFT_CHANNEL=stable

ENV SNAPCRAFT_URL=https://api.snapcraft.io/api/v1/snaps/details/snapcraft?channel=${SNAPCRAFT_CHANNEL}
# Install curl, used later
# install https for apt
# install git used by snapcraft
RUN apt-get update && \
apt-get full-upgrade --yes && \
apt-get install -y --no-install-recommends \
apt-utils \
ca-certificates \
curl \
apt-transport-https \
git && \
# Import the public repository GPG keys for Microsoft
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
# Register the Microsoft Ubuntu 16.04 repository with apt
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | tee /etc/apt/sources.list.d/microsoft.list && \
# Update after register new repo
apt-get update && \
# Install Powershell
apt-get install --yes \
powershell && \
# Clean up so the layer is small
apt remove --yes --purge apt-utils apt-transport-https && \
apt-get autoclean --yes && \
apt-get clean --yes && \
rm /etc/apt/sources.list.d/microsoft.list
RUN echo SNAPCRAFT_URL: ${SNAPCRAFT_URL} && \
apt-get update && \
apt-get dist-upgrade --yes && \
apt-get install --yes \
curl \
sudo \
jq \
squashfs-tools \
git && \
curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core' | jq '.download_url' -r) --output core.snap && \
mkdir -p /snap/core && unsquashfs -d /snap/core/current core.snap && rm core.snap && \
# curl -L $(curl -H 'X-Ubuntu-Series: 16' 'https://api.snapcraft.io/api/v1/snaps/details/core18' | jq '.download_url' -r) --output core18.snap && \
# mkdir -p /snap/core18 && unsquashfs -d /snap/core18/current core18.snap && rm core18.snap && \
curl -L $(curl -H 'X-Ubuntu-Series: 16' ${SNAPCRAFT_URL} | jq '.download_url' -r) --output snapcraft.snap && \
mkdir -p /snap/snapcraft && unsquashfs -d /snap/snapcraft/current snapcraft.snap && rm snapcraft.snap && \
apt remove --yes --purge jq squashfs-tools && \
apt-get autoclean --yes && \
apt-get clean --yes

COPY snapcraft-wrapper /snap/bin/snapcraft

ENV PATH=/snap/bin:$PATH

COPY powershell-snap.ps1 /powershell-snap.ps1
COPY powershell-snap.sh /powershell-snap.sh
Expand Down
12 changes: 8 additions & 4 deletions tools/releaseBuild/build.json
Expand Up @@ -7,7 +7,8 @@
"BuildCommand": "/powershell-snap.sh -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_",
"AdditionalContextFiles": [
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.sh",
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1"
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1",
"./tools/releaseBuild/Images/GenericLinuxFiles/snapcraft-wrapper"
],
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile",
"DockerImageName": "ps-snap-ubunutu-16-04",
Expand All @@ -19,7 +20,8 @@
"BuildCommand": "/powershell-snap.sh -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -Preview",
"AdditionalContextFiles": [
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.sh",
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1"
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1",
"./tools/releaseBuild/Images/GenericLinuxFiles/snapcraft-wrapper"
],
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile",
"DockerImageName": "ps-snap-ubunutu-16-04",
Expand All @@ -31,7 +33,8 @@
"BuildCommand": "/powershell-snap.sh -location _RepoDestinationPath_ -destination _DockerVolume_",
"AdditionalContextFiles": [
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.sh",
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1"
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1",
"./tools/releaseBuild/Images/GenericLinuxFiles/snapcraft-wrapper"
],
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile",
"DockerImageName": "ps-snap-ubunutu-16-04",
Expand All @@ -43,7 +46,8 @@
"BuildCommand": "/powershell-snap.sh -location _RepoDestinationPath_ -destination _DockerVolume_ -preview",
"AdditionalContextFiles": [
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.sh",
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1"
"./tools/releaseBuild/Images/GenericLinuxFiles/powershell-snap.ps1",
"./tools/releaseBuild/Images/GenericLinuxFiles/snapcraft-wrapper"
],
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile",
"DockerImageName": "ps-snap-ubunutu-16-04",
Expand Down