Skip to content

Commit

Permalink
Preview support (#4782)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
  • Loading branch information
halkeye and timja authored Jan 6, 2022
1 parent 7f90be0 commit ac95b61
Show file tree
Hide file tree
Showing 9 changed files with 37,769 additions and 1,397 deletions.
48 changes: 48 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.DS_Store
.gradle/
build/
*.sw*
.awestruct/

# Ignore merge files
*.orig

# Ignore Intellij files
.idea
*.iml

# Ignore vscode files
.vscode/

# nodejs
node_modules/
.npm/

# ruby
.bundle/
vendor/
.config/

# external - see scripts/fetch-external-resources
content/_tmp/
content/_data/_generated/


# external - files unzipped from /content/_tmp/
# generated pipeline step documentation
content/doc/pipeline/steps/*.adoc

# generated extension points documentation
content/doc/developer/extensions/*.adoc


# unknown
.sass-cache/
_site
_tmp/
content/_site/

Dockerfile
.gitignore
.dockerignore
.git
49 changes: 18 additions & 31 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,40 @@
FROM node:alpine as node
FROM node:16.13.1 as node
ENV USE_LOCAL_NODE=true

WORKDIR /usr/src/jenkinsio/_site/
ENV ASSETS_DIR=/usr/src/jenkinsio/_site/assets/bower
ENV FONTS_DIR=/usr/src/jenkinsio/_site/css/fonts
WORKDIR /usr/src/jenkinsio/build/_site/
ENV ASSETS_DIR=/usr/src/jenkinsio/build/_site/assets/bower
ENV FONTS_DIR=/usr/src/jenkinsio/build/_site/css/fonts

COPY package* ./
COPY Makefile package* ./
COPY scripts ./scripts

RUN npm install
RUN mkdir -p assets/bower css/fonts

RUN find node_modules \( -iname "*.eot" -o -iname "*.woff" -o -iname "*.ttf" \) -not -path "./node_modules/.cache/*" >> $$line ;\
while read -r line; do\
echo "Copying $line into assets/bower"; \
cp "$line" assets/bower; \
done < $$line

RUN for d in bootstrap jquery tether; do \
echo "Copying node_modules/$d/dist/* into assets/bower/$d/"; \
mkdir -p assets/bower/$d; \
cp -R node_modules/$d/dist/* assets/bower/$d/ ; \
done;
RUN mkdir -p assets/bower/anchor-js/ assets/bower/ionicons
RUN cp node_modules/anchor-js/*.js assets/bower/anchor-js/
RUN cp -R node_modules/ionicons/dist/css assets/bower/ionicons
RUN cp -R node_modules/ionicons/dist/fonts assets/bower/ionicons

FROM ruby:2.6 as builder
RUN make assets

FROM ruby:2.6.9 as builder
ENV USE_LOCAL_RUBY=true

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1

WORKDIR /usr/src/jenkinsio

COPY Gemfile Gemfile.lock ./
COPY Makefile Gemfile Gemfile.lock ./
RUN bundle install

COPY scripts scripts
COPY content content

RUN mkdir _site
COPY --from=node /usr/src/jenkinsio/_site/assets/bower ./_site/assets/bower
COPY --from=node /usr/src/jenkinsio/_site/css/fonts ./_site/css/fonts
RUN bundle exec ./scripts/release.rss.rb 'https://updates.jenkins.io/release-history.json' > ./_site/releases.rss
RUN mkdir -p ./build/_site
COPY --from=node /usr/src/jenkinsio/build/_site/assets/bower ./build/_site/assets/bower
COPY --from=node /usr/src/jenkinsio/build/_site/css/fonts ./build/_site/css/fonts
RUN bundle exec ./scripts/release.rss.rb 'https://updates.jenkins.io/release-history.json' > ./build/_site/releases.rss
RUN bundle exec ./scripts/fetch-external-resources
RUN awestruct --generate --verbose --source-dir=content --output-dir=./_site
RUN make real_generate


FROM nginx:1.17

COPY --from=builder /usr/src/jenkinsio/_site /usr/share/nginx/html
COPY --from=builder /usr/src/jenkinsio/build/_site /usr/share/nginx/html

COPY docker/default.conf /etc/nginx/conf.d/default.conf
137 changes: 126 additions & 11 deletions Jenkinsfile_k8s
Original file line number Diff line number Diff line change
@@ -1,18 +1,133 @@
#!/usr/bin/env groovy
def recordDeployment(owner, repo, ref, status, environmentURL, environment = "preview", description = "Deploy to preview environment") {
withCredentials([usernamePassword(credentialsId: 'github-app-infra', usernameVariable: 'GITHUB_APP', passwordVariable: 'GH_TOKEN')]) {
def json = writeJSON(returnText: true, json: [
"ref": ref,
"environment": environment,
"description": description,
"required_contexts": [],
"auto_merge": false,
"auto_inactive": false,
"transient_environment": false,
])
def id = readJSON(text: sh(script: "gh api repos/${owner}/${repo}/deployments -X POST --input - << EOF\n${json}\nEOF", returnStdout: true).trim()).id
if (id == ''){
error('Unable to create deployment')
}
json = writeJSON(returnText: true, json: [
"state": status,
"environment": environment,
"description": description,
"log_url": "${BUILD_URL}console",
"environment_url": environmentURL,
"log_url": "${BUILD_URL}console",
])
sh("gh api repos/${owner}/${repo}/deployments/${id}/statuses -X POST --input - << EOF\n${json}\nEOF")
}
}

pipeline {
agent {
kubernetes {
yaml '''
apiVersion: "v1"
kind: "Pod"
metadata:
labels:
jenkins: "agent"
job: "jenkins-io"
spec:
tolerations:
- key: "os"
operator: "Equal"
value: "linux"
effect: "NoSchedule"
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/os
operator: In
values:
- linux
restartPolicy: "Never"
automountServiceAccountToken: false
containers:
- name: "jnlp"
image: "jenkinsciinfra/builder:2.0.3"
resources:
limits: {}
requests:
memory: "4Gi"
cpu: "2"
'''
}
}

environment {
TZ = "UTC"
USE_LOCAL_NODE = "true"
USE_LOCAL_RUBY = "true"
}

triggers {
cron("${env.BRANCH_NAME == 'master' ? 'H/30 * * * *' : ''}")
}

options {
timeout(time: 60, unit: 'MINUTES')
ansiColor('xterm')
disableConcurrentBuilds(abortPrevious: true)
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5')
}

/* Only keep the 10 most recent builds. */
def projectProperties = [
[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],
]
stages {
stage('NPM Install') {
steps {
sh 'npm install'
}
}

def principalBranch = 'master'
stage('Bundle Install') {
steps {
// throw errors if Gemfile has been modified since Gemfile.lock
sh '''
bundle config --global frozen 1
bundle install
'''
}
}

/* Start by building the image, and eventually pushing it if the execution is on the master branch */
buildDockerAndPublishImage('jenkinsio', [mainBranch: principalBranch])
stage('Build') {
steps {
sh 'make'
}
}

if (env.BRANCH_NAME == principalBranch) {
withCredentials([string(credentialsId: 'updatecli-github-token', variable: 'UPDATECLI_GITHUB_TOKEN')]) {
stage('Deploy to preview site') {
when {
changeRequest target: 'master'
}
environment {
NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token')
}
post {
success {
recordDeployment('jenkins-infra', 'jenkins.io', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--jenkins-io-site-pr.netlify.app")
}
failure {
recordDeployment('jenkins-infra', 'jenkins.io', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--jenkins-io-site-pr.netlify.app")
}
}
steps {
script {
def netlifySite = readJSON(text: sh(script: 'npx netlify sites:list --json', returnStdout: true).trim()).find { it.name == "jenkins-io-site-pr" }
env.NETLIFY_SITE_ID = netlifySite['site_id']
env.NETLIFY_DOMAIN = netlifySite['default_domain']

updatecli(action: 'apply')
sh('npx netlify deploy --message "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d build/_site')
}
}
}
}
}
24 changes: 13 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

BUILD_DIR=build
OUTPUT_DIR=$(BUILD_DIR)/_site
BUILD_DIR ?= build
OUTPUT_DIR ?= $(BUILD_DIR)/_site
AWESTRUCT_CONFIG=--source-dir=content --output-dir=$(OUTPUT_DIR)
ASSETS_DIR=$(OUTPUT_DIR)/assets/bower
FONTS_DIR=$(OUTPUT_DIR)/css/fonts
VERSION=$(BUILD_NUMBER)-$(shell git rev-parse --short HEAD)
GITHUB_USER=$(USER)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
USER_SITE_URL=https://$(GITHUB_USER).github.io/jenkins.io/$(BRANCH)/
AWESTRUCT_USER_SITE=-P user-site --url "$(USER_SITE_URL)"
DOCKER_ORG?=jenkinsciinfra
ASSETS_DIR ?= $(OUTPUT_DIR)/assets/bower
FONTS_DIR ?= $(OUTPUT_DIR)/css/fonts
VERSION ?= $(BUILD_NUMBER)-$(shell git rev-parse --short HEAD)
GITHUB_USER ?= $(USER)
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
USER_SITE_URL ?= https://$(GITHUB_USER).github.io/jenkins.io/$(BRANCH)/
AWESTRUCT_USER_SITE ?= -P user-site --url "$(USER_SITE_URL)"
DOCKER_ORG ?= jenkinsciinfra

# Generate everything
all: fetch-reset prepare generate archive
Expand All @@ -21,7 +21,9 @@ run: prepare scripts/awestruct

generate: site

site: prepare scripts/awestruct
site: prepare scripts/awestruct real_generate

real_generate:
./scripts/awestruct --generate --verbose $(AWESTRUCT_CONFIG)

check-broken-links: site
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
- interview
:author: rtyler
---
For this week's user spotlight segment, I'm talking with https://twitter.com/dougmaceachern[Doug MacEachern] of https://www.crunchbase.com/company/hyperic[Hyperic], part of https://www.crunchbase.com/company/springsource[SpringSource], a division of VMware, hoping I got that dependency chain correct. Hyperic builds enterprise systems monitoring and management software and also contributes to a number of open source projects, many of which are built with Hudson. image:http://blog.hudson-ci.org/sites/default/files/hyperic_hudson.png[A small subsection of Hyperic's Hudson,350,link=http://blog.hudson-ci.org/sites/default/files/hyperic_hudson.png]
For this week's user spotlight segment, I'm talking with https://twitter.com/dougmaceachern[Doug MacEachern] of https://www.crunchbase.com/company/hyperic[Hyperic], part of https://www.crunchbase.com/company/springsource[SpringSource], a division of VMware, hoping I got that dependency chain correct. Hyperic builds enterprise systems monitoring and management software and also contributes to a number of open source projects, many of which are built with Hudson.

To date I must say that Doug's use of Hudson is one of the largest and more impressive installations I've seen. I don't want to spoil the interview, but they're testing on platforms that don't even run _Java_. Madness! If you think you can out-do him, you can find my email information at the bottom of the interview, I'd love to hear about it!

Expand Down
2 changes: 1 addition & 1 deletion content/blog/2012/2012-05-28-jenkins-a-besoin-de-vous.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
---
[*Editor's Note*: _The following is a guest post by Jenkins contributor https://twitter.com/bmathus[Baptiste Mathus]. For the non-French speakers, we're looking for French speakers to help translate "Jenkins: The Definitive Guide"_ ]

image::http://batmat.net/dotclear/public/images/Superdupont_we_need_you.jpg[Woui Nide You!,180]
image::https://batmat.net/dotclear/public/images/Superdupont_we_need_you.jpg[Woui Nide You!,180]

Si vous vous intéressez à Jenkins et que vous aimeriez pouvoir y contribuer, lisez la suite.

Expand Down
Loading

0 comments on commit ac95b61

Please sign in to comment.