| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| def NODE = 'git-websites' |
| def VALID_ASF_YAML = '3381ad5637eb525502df319e84b7208e8f2a977b' |
| |
| pipeline { |
| agent { |
| label "$NODE" |
| } |
| |
| options { |
| buildDiscarder( |
| logRotator(artifactNumToKeepStr: '1', numToKeepStr: '1') |
| ) |
| |
| checkoutToSubdirectory('camel-website') |
| } |
| |
| environment { |
| ANTORA_CACHE_DIR = "$WORKSPACE/.antora-cache" |
| CAMEL_ENV = 'production' |
| GITHUB = credentials('399061d0-5ab5-4142-a186-a52081fef742') // asf-ci credential |
| HUGO_CACHEDIR = "$WORKSPACE/.hugo-cache" |
| } |
| |
| stages { |
| stage('Website') { |
| agent { |
| dockerfile { |
| dir 'camel-website' |
| label "$NODE" |
| reuseNode true |
| args '-u root' |
| } |
| } |
| |
| environment { |
| HOME = "$WORKSPACE" |
| } |
| |
| steps { |
| sh "cd $WORKSPACE/camel-website && yarn install && yarn clean && yarn workspaces foreach --all install; HUGO_PARAMS_GitHubUsername=$GITHUB_USR HUGO_PARAMS_GitHubToken=$GITHUB_PSW yarn build-all" |
| } |
| } |
| |
| stage('Setup') { |
| steps { |
| sh "$WORKSPACE/camel-website/support/docker-pipe.sh $WORKSPACE/docker-pipe &" |
| } |
| } |
| |
| stage('Checks') { |
| agent { |
| dockerfile { |
| dir 'camel-website' |
| label "$NODE" |
| reuseNode true |
| args "-u root -v $WORKSPACE/docker-pipe/docker:/usr/bin/docker" |
| } |
| } |
| |
| environment { |
| HOME = "$WORKSPACE" |
| } |
| |
| steps { |
| sh "cd $WORKSPACE/camel-website && yarn checks" |
| } |
| } |
| |
| stage('Deploy') { |
| when { |
| branch 'main' |
| } |
| |
| steps { |
| dir('deploy/live') { |
| deleteDir() |
| sh 'git clone -b asf-site https://gitbox.apache.org/repos/asf/camel-website-pub.git .' |
| sh "rsync -a --delete --exclude='.git' --exclude='.asf.yaml' $WORKSPACE/camel-website/public/ ." |
| sh 'git add -A' |
| sh "git checkout $VALID_ASF_YAML -- ./.asf.yaml" // force revert to commit containing the valid .asf.yml |
| sh 'echo "Website publish: $(git diff --cached --numstat | wc -l | tr -d " ") files changed"' |
| sh 'git diff-index --quiet HEAD || git commit -m "Website updated to $GIT_COMMIT"' |
| sh 'git push origin asf-site' |
| sh 'sleep 5' |
| sh 'git commit --allow-empty -m "CDN cache invalidation"' |
| sh 'git push origin asf-site' |
| } |
| } |
| } |
| } |
| |
| post { |
| always { |
| sh "[ -x $WORKSPACE/docker-pipe/teardown.sh ] && $WORKSPACE/docker-pipe/teardown.sh || true" |
| } |
| fixed { |
| mail subject: 'Website build status', body: "🥳 Build succeeded!", to: 'camel-website.874fb06555c2b4407efde9f9a3b13c13.show-sender@streams.zulipchat.com' |
| } |
| unsuccessful { |
| mail subject: 'Website build status', body: "😞 Build failed. Please have a look at the build output at: ${env.BUILD_URL}", to: 'camel-website.874fb06555c2b4407efde9f9a3b13c13.show-sender@streams.zulipchat.com' |
| } |
| } |
| } |