Search code examples
bashdebianpipeline

Pipeline Shell Script Permission Issue on .NET Build Attempt


I am trying to build an ASP.NET5 application via Bluemix Pipeline using a shell script to configure a runtime that supports .NET builds with DNVM. When building the application we need to get dependencies from Mono 4.0 (such as kestrel) but the latest Mono available via apt-get is 3.2. I tried to resolve this by adding the Mono deb repository in /etc/apt/sources.list so that an apt-get update would fetch the latest Mono package but due to a permission error we are not allowed to alter sources.list nor add or alter any files in /etc/apt/sources.list.d/*.

For example, running:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
sudo echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo -i tee /etc/apt/sources.list.d/mono-xamarin.list

Will result in:

sudo: no tty present and no askpass program specified

Not using sudo will give a permission issue and I think we have exhausted all possible workarounds such as ssh -t -t and forth.

Does anyone have any suggestions on a workaround for this or an alternative method to run a shell script where a .NET build with DNVM and all dependencies would be supported? Using another language or cf push in this case is not an option, we really want to push .NET through pipeline at any cost.


Solution

  • When experimenting with the pipeline I wasn't able to get it working with Mono either, but if you can get away with just the CoreCLR on Linux then you should be able to. Kestrel, for example, doesn't require Mono anymore.

    This was a build script from the beta7 timeframe but it should be close to what's needed to use RC1 now:

    #!/bin/bash
    
    sudo apt-get update
    sudo apt-get -y install libunwind8 gettext libssl-dev libcurl3-dev zlib1g
    
    curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh
    dnvm install 1.0.0-beta7 -r coreclr -a x64
    
    cd src/dotnetstarter
    dnu restore
    dnu build
    
    cd ../../test/dotnetstarter.tests
    dnu restore
    dnu build
    dnx test
    
    cd ../../src/dotnetstarter
    dnu publish --runtime ~/.dnx/runtimes/dnx-coreclr-linux-x64.1.0.0-beta7
    

    The app was https://github.com/IBM-Bluemix/asp.net5-helloworld and I added the dotnetstarter.tests project which I was trying to run in the pipeline (the dnx test step). The last publish step isn't required but is included to show it was working.