FILE: /var/lib/jenkins/workspace/camelsoft-website-api/Jenkinsfile // camel-soft.com — lead API pipeline. // Builds the Spring Boot jar, publishes it to /opt/camelsoft-website-api and // restarts only this service. Port 8090, nothing else on the server is touched. pipeline { agent any options { timestamps() disableConcurrentBuilds() buildDiscarder(logRotator(numToKeepStr: '15')) timeout(time: 20, unit: 'MINUTES') } environment { APP_DIR = '/opt/camelsoft-website-api' SERVICE = 'camelsoft-website-api' HEALTH = 'http://127.0.0.1:8090/actuator/health' } stages { stage('Checkout') { steps { checkout scm } } stage('Build') { steps { sh 'mvn -B -ntp -DskipTests clean package' } } stage('Deploy') { steps { sh ''' JAR=$(ls target/website-api-*.jar | head -1) echo "publishing $JAR" cp "$JAR" "$APP_DIR/app.jar.new" mv -f "$APP_DIR/app.jar.new" "$APP_DIR/app.jar" sudo /bin/systemctl restart "$SERVICE" ''' } } stage('Health check') { steps { sh ''' for i in $(seq 1 30); do sleep 3 if curl -fsS "$HEALTH" | grep -q '"status":"UP"'; then echo "API is UP"; exit 0 fi done echo "API did not become healthy — check: journalctl -u $SERVICE / /var/log/camelsoft-website-api/app.log" exit 1 ''' } } } post { failure { echo 'Build or health check failed — the previous jar is still on disk.' } } } FILE: /var/lib/jenkins/workspace/camelsoft-website/Jenkinsfile // camel-soft.com — front-end pipeline. // Builds the React site (prerendered HTML + sitemaps) and publishes it to the // folder nginx serves. Nothing here touches other projects on the server. pipeline { agent any tools { nodejs 'Node_22' } options { timestamps() disableConcurrentBuilds() buildDiscarder(logRotator(numToKeepStr: '15')) timeout(time: 20, unit: 'MINUTES') } environment { DEPLOY_DIR = '/var/www/camel-soft.com/current' SITE_URL = 'https://camel-soft.com' } stages { stage('Checkout') { steps { checkout scm } } stage('Configure') { steps { // Public keys (GA4, Meta Pixel, reCAPTCHA site key, Maps) come from a // Jenkins "Secret file" credential so they are not committed. // The credential file is read-only, so copy its contents (not its mode). withCredentials([file(credentialsId: 'camelsoft-website-env', variable: 'ENV_FILE')]) { sh ''' rm -f .env.production cat "$ENV_FILE" > .env.production # The credential may not end with a newline; without this the next # line would be glued onto its last value (it corrupted the Maps key). printf '\nVITE_SITE_URL=%s\n' "$SITE_URL" >> .env.production chmod 600 .env.production echo "build config: $(grep -c . .env.production) settings" ''' } } } stage('Install') { steps { sh 'npm ci --no-audit --no-fund' } } stage('Build') { steps { sh 'npm run build' } } stage('Verify build') { steps { sh ''' test -f dist/index.html test -f dist/ar/index.html test -f dist/sitemap_index.xml test -f dist/robots.txt echo "pages: $(find dist -name index.html | wc -l)" ''' } } stage('Deploy') { steps { sh ''' mkdir -p "$DEPLOY_DIR" rsync -a --delete --omit-dir-times dist/ "$DEPLOY_DIR"/ echo "deployed $(find "$DEPLOY_DIR" -name index.html | wc -l) pages to $DEPLOY_DIR" ''' } } // Only meaningful once the domain points at the new site (after cutover). // Never fails the build: the deployed files were already verified above. stage('Smoke test') { steps { catchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE') { sh ''' for u in / /ar/ /sitemap_index.xml; do printf "%-20s %s\\n" "$u" "$(curl -s -o /dev/null -w '%{http_code}' https://camel-soft.com$u)" done ''' } } } } post { success { echo "Deployed to ${env.SITE_URL}" } failure { echo 'Build failed — the site on the server was left untouched.' } } } java.io.IOException: Stream closed at java.base/java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:206) at java.base/java.io.BufferedInputStream.implRead(BufferedInputStream.java:411) at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:405) at java.base/sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:350) at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:393) at java.base/sun.nio.cs.StreamDecoder.lockedRead(StreamDecoder.java:217) at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:171) at java.base/java.io.InputStreamReader.read(InputStreamReader.java:188) at java.base/java.io.BufferedReader.read1(BufferedReader.java:223) at java.base/java.io.BufferedReader.implRead(BufferedReader.java:314) at java.base/java.io.BufferedReader.read(BufferedReader.java:296) at java.base/java.io.Reader.read(Reader.java:265) at org.codehaus.groovy.runtime.IOGroovyMethods.getText(IOGroovyMethods.java:892) at org.codehaus.groovy.runtime.IOGroovyMethods.getText(IOGroovyMethods.java:843) at org.codehaus.groovy.runtime.dgm$834.doMethodInvoke(Unknown Source) at org.codehaus.groovy.reflection.GeneratedMetaMethod$Proxy.doMethodInvoke(GeneratedMetaMethod.java:83) at org.codehaus.groovy.runtime.metaclass.MethodMetaProperty$GetBeanMethodMetaProperty.getProperty(MethodMetaProperty.java:76) at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:299) at Script1.run(Script1.groovy:4) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:574) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:612) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:583) at hudson.util.RemotingDiagnostics$Script.evaluateScript(RemotingDiagnostics.java:171) at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:160) at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:130) at hudson.remoting.LocalChannel.call(LocalChannel.java:47) at hudson.util.RemotingDiagnostics.executeGroovy(RemotingDiagnostics.java:125) at jenkins.model.Jenkins._doScript(Jenkins.java:4885) at jenkins.model.Jenkins.doScriptText(Jenkins.java:4850) at java.base/java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:733) at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:484) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:497) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:218) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:140) at org.kohsuke.stapler.MetaClass$12.doDispatch(MetaClass.java:686) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:61) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:800) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:938) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:721) at org.kohsuke.stapler.Stapler.service(Stapler.java:253) at Jenkins Main ClassLoader//jakarta.servlet.http.HttpServlet.service(HttpServlet.java:587) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHolder.handle(ServletHolder.java:783) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1670) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:200) at PluginClassLoader for locale//hudson.plugins.locale.LocaleFilter.doFilter(LocaleFilter.java:82) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:197) at jenkins.util.HttpServletFilter$1.doFilter(HttpServletFilter.java:77) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:197) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:203) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at jenkins.ErrorAttributeFilter.doFilter(ErrorAttributeFilter.java:29) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:153) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at jenkins.security.csp.impl.CspFilter.doFilter(CspFilter.java:83) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:94) at jenkins.security.AcegiSecurityExceptionFilter.doFilter(AcegiSecurityExceptionFilter.java:52) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:54) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:125) at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:100) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:114) at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:105) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:235) at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:229) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:106) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:117) at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:63) at hudson.security.ChainedServletFilter2$1.doFilter(ChainedServletFilter2.java:99) at hudson.security.ChainedServletFilter2.doFilter(ChainedServletFilter2.java:111) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:173) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at org.kohsuke.stapler.UncaughtExceptionFilter.doFilter(UncaughtExceptionFilter.java:26) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:85) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:31) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at jenkins.security.SuspiciousRequestFilter.doFilter(SuspiciousRequestFilter.java:38) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.FilterHolder.doFilter(FilterHolder.java:202) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1640) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler.doHandle(ServletHandler.java:526) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.handle(ScopedHandler.java:125) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.security.SecurityHandler.handle(SecurityHandler.java:574) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.HandlerWrapper.handle(HandlerWrapper.java:124) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.nextHandle(ScopedHandler.java:195) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.SessionHandler.doHandle(SessionHandler.java:612) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.nextHandle(ScopedHandler.java:193) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ContextHandler.doHandle(ContextHandler.java:1047) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.nextScope(ScopedHandler.java:162) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.servlet.ServletHandler.doScope(ServletHandler.java:483) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.nextScope(ScopedHandler.java:160) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.SessionHandler.doScope(SessionHandler.java:589) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.nextScope(ScopedHandler.java:160) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ContextHandler.doScope(ContextHandler.java:962) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ScopedHandler.handle(ScopedHandler.java:123) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ContextHandler.handle(ContextHandler.java:1731) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1586) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.HttpChannel.dispatch(HttpChannel.java:737) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.HttpChannel.handle(HttpChannel.java:520) at Jenkins Main ClassLoader//org.eclipse.jetty.ee9.nested.ContextHandler$CoreContextHandler$CoreToNestedHandler.handle(ContextHandler.java:3059) at Jenkins Main ClassLoader//org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1226) at Jenkins Main ClassLoader//org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:621) at Jenkins Main ClassLoader//org.eclipse.jetty.server.Server.handle(Server.java:197) at Jenkins Main ClassLoader//org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:788) at Jenkins Main ClassLoader//org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:420) at Jenkins Main ClassLoader//org.eclipse.jetty.server.internal.HttpConnection$FillableCallback.succeeded(HttpConnection.java:1809) at Jenkins Main ClassLoader//org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105) at Jenkins Main ClassLoader//org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:54) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:492) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.epcRunTask(AdaptiveExecutionStrategy.java:428) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:401) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:255) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:204) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:317) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:1009) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1240) at Jenkins Main ClassLoader//org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1194) at java.base/java.lang.Thread.run(Thread.java:1583)