jenkinsci / azure-container-agents-plugin

Azure Container Agents Plugin for Jenkins
https://plugins.jenkins.io/azure-container-agents/
MIT License
19 stars 26 forks source link

How to use with Declarative Pipeline and docker agent #20

Open sheerun opened 6 years ago

sheerun commented 6 years ago

Hello,

I'm trying to make my declarative pipeline run on azure container instances without employing something like docker in docker. Is there a way to enable something so Jenkinsfile like this could work out of the box on Azure Container Instances?

pipeline {
    agent {
        docker { image 'node:7-alpine' }
    }
    stages {
        stage('Test') {
            steps {
                sh 'node --version'
            }
        }
    }
}

Here's documentation: https://jenkins.io/doc/book/pipeline/docker/

EDIT: Actually it seems docker in docker doesn't even work on Container Instances

zackliu commented 6 years ago

Docker in docker isn't supported in ACI but supported in ACS

zackliu commented 6 years ago

Hi, what your purpose to use Docker inside a container. If you need some specific environment, you can just prepare such a Docker image with JNLP or SSH and use it as agent directly.

sheerun commented 6 years ago

I don't need docker inside container (well, I'd like to have it for building images and testing images along services, but that's other matter). The only reason I mentioned dind is that I thought it could workaround my issue by running docker commands inside steps, instead of configuring proper image as agent.

This issue is only about ability to run declarative pipeline that I've mentioned, on ACI runtime.

I've modified the title of issue to better reflect it.

zackliu commented 6 years ago

Sorry, I need to make the issue more clearly. What you want to achieve is if you use the Jenkinsfile above, actually Jenkins will provision an azure container instance with nodejs image to run the following commands. Is my understanding correct?

sheerun commented 6 years ago

That's correct :) The point is to be able to run above pipeline unmodified on both ACI and ACS.

mitchellmaler commented 6 years ago

I am also wondering the same thing.

Using Jenkins declarative pipeline can you use the specified ACI cloud but in the pipeline/jenkinsfile specify the image to deploy and use for the job.

This way we don't have to manually specify the templates but it can be done in the jobs jenkinsfile.

nerumo commented 6 years ago

@zackliu you said it works in acs. So if a build requests a part to run in a specific docker image (without jnlp) it should provision a container and run stuff in there?