Skip to content

Instantly share code, notes, and snippets.

@LiberQuack
Last active December 4, 2018 23:20
Show Gist options
  • Save LiberQuack/09d2cb28fbd751ec05b1f563c45a65b2 to your computer and use it in GitHub Desktop.
Save LiberQuack/09d2cb28fbd751ec05b1f563c45a65b2 to your computer and use it in GitHub Desktop.
Script for installing a brand new Jenkins

Blueocean Setup

Start blueocean container by running the script bellow

docker network create ci_network &&

echo '
global
   log             127.0.0.1       local0  debug
   maxconn         1000
   daemon

defaults
   timeout connect 5000
   timeout client  50000
   timeout server  50000
   retries         3
   log             global
   mode    http
   option  httplog
   option forwardfor
   option  http-server-close

frontend www-http
   bind               *:80
   reqadd             X-Forwarded-Proto:\ http
   default_backend    jenkins
   acl is_root        path -i /
   redirect           code 301 location /jenkins/blue if is_root
   acl ci_jenkins     path_beg    /jenkins
   use_backend        jenkins if ci_jenkins

frontend www-https
   bind               *:443 ssl crt /etc/letsencrypt/live/ci.finanzero.com.br/ci.finanzero.com.br.pem
   reqadd             X-Forwarded-Proto:\ https
   default_backend    jenkins
   acl is_root        path -i /
   redirect           code 301 location /jenkins/blue if is_root
   acl ci_jenkins     path_beg    /jenkins
   use_backend        jenkins if ci_jenkins

backend jenkins
   server          ci_jenkins         ci_jenkins:8080
' > /haproxy.cfg &&

docker run -d \
    -p 80:80 \
    -p 443:443 \
    --name ci_haproxy \
    --restart always \
    --network ci_network \
    -v /etc/letsencrypt:/etc/letsencrypt \
    -v /haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg \
    haproxy:1.8-alpine &&

docker run -d \
  -u root \
  --network ci_network \
  -e JENKINS_OPTS="--prefix=/jenkins" \
  -v /jenkins:/var/jenkins_home \
  -v /root/.ssh:/root/.ssh \
  -v /root/.aws:/root/.aws \
  -v /var/run/docker.sock:/var/run/docker.sock \
  --name ci_jenkins \
  --restart always \
  jenkinsci/blueocean:1.9.0 &&

mkdir -p /root/.ssh &&
echo "StrictHostKeyChecking no" >> /root/.ssh/config &&

docker exec -it ci_jenkins bash -c '
    which rdocker || curl -L https://github.com/dvddarias/rdocker/raw/master/rdocker.sh > /usr/local/bin/rdocker && chmod +x /usr/local/bin/rdocker
    apk add --no-cache python py-pip #Needed to run rdocker
    pip install docker-compose
    pip install --upgrade --user awscli 
    ln -sf /root/.local/bin/aws /usr/bin/aws
    $(aws ecr get-login --no-include-email --region sa-east-1) || echo "Login to AWS ECR not possible... Did you create and attached a role to this server?"
' &&

service docker restart

Displays its logs and find admin then proceed through browser... Then prefer installing the default plugins

docker container logs -f blueocean

Go to Jenkins > Configure Global Security and check

Allow anonymous read access

Interesting Plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment