-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Tim Jacomb <21194782+timja@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
37,769 additions
and
1,397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.