Search code examples
jenkinscontinuous-integrationjenkins-pluginscontinuous-deliveryjenkins-2

Jenkins 2 override plugins.txt


I´m migrating from Jenkins 1.6 to Jenkins 2.0. I was using docker to create and run Jenkins.

And in order to configure as immutable jenkins, we used to copy all xml config files and use plugins.txt to install all necessary plugins.

But problem now is, after we init Jenkins and I connect I only see a wizard screen which ask me for a admin password, which is in a path. After put that password he ask for install plugins, which I was expecting to be installed already.

Once that I finish that wizard I don't have any plugin installed of my plugins.txt list, or I have any user passed in the users folder.

Any idea how to fix this?. in Jenkins 1.6 everything works fine.


Solution

  • Where do you put your plugins.txt? The content of plugins.txt will be installed inside jenkins when you build your image. So you need to rebuild jenkins:2.0 with your own dockerfile.

    FROM jenkins:2.0
    COPY plugins.txt /usr/share/jenkins/plugins.txt
    RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt
    

    Put the plugins.txt script inside the same folder. Content of my plugins.txt

    greenballs:1.15
    

    Than build your image with docker build -t my-jenkins:2.0 .

    I don't know how you are migrating your jobs but I would think something like deleting the old jenkins container but keeping the persistent docker volume (or mapped folder on your host to which you're mounting). But After the build of the new jenkins start the jenkins using the -v option to bind to your old volume.

    $ docker run -d -v /content-folder:/var/jenkins_home -p 8080:8080 my-jenkins:2.0
    

    Jenkins will start with the plugins already installed + the content of your 1.6 configuration.

    I was only able to test the part with the plugins and it worked for me. After the docker build I performed docker run -d -p 8080:8080 my-jenkins:2.0. Checked the docker logs of that container to grab the initialAdminPassword. Didn't install any plugin in the editor and created a job. After a succesful run I saw the greenball instead of the blue.