# TODO:
# - https://plugins.jenkins.io/configuration-as-code/
# - https://plugins.jenkins.io/job-dsl/
# - https://plugins.jenkins.io/jobConfigHistory/
# - https://plugins.jenkins.io/github-pullrequest/
# - https://plugins.jenkins.io/ansicolor/
# - https://plugins.jenkins.io/timestamper/
# - https://plugins.jenkins.io/claim/
# - https://plugins.jenkins.io/mailer/
plugins="
    blueocean
    pipeline-multibranch-defaults
"

# https://github.com/jenkinsci/docker/blob/master/README.md#usage

id="$(
    docker run \
        -d \
        -v jenkins_home:/var/jenkins_home \
        -p 8080:8080 \
        -p 50000:50000 \
        jenkins/jenkins:lts \
    | tee /dev/tty \
    | tail -n 1
)"

password="$(
    docker exec "$id" \
        cat /var/jenkins_home/secrets/initialAdminPassword
)"

docker exec "$id" \
    /usr/local/bin/install-plugins.sh $plugins

JENKINS_URL="localhost:8080"

curl "$JENKINS_URL/safeRestart"