I have a java web application deployed in app engine and the source code is in Bitbucket under master branch,
And I heard about bitbucket pipelines I found it helpful as a fast way of auto deploying
My master branch having this list of 4 projects:
master --
|- project1
|- project2
|- project3
|- project4
|- bitbucket-pipelines.yml
And I followed exactly what is written in this link to provide the pipeline functionality:
https://confluence.atlassian.com/bitbucket/deploy-to-google-cloud-900820342.html
and here is my bitbucket-pipelines.yml content and its located directly under my master branch
image: maven:3.3.9
pipelines:
branches:
master:
- step:
caches:
- maven
script:
# Downloading the Google Cloud SDK
- curl -o /tmp/google-cloud-sdk.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-155.0.0-linux-x86_64.tar.gz
- tar -xvf /tmp/google-cloud-sdk.tar.gz -C /tmp/
- /tmp/google-cloud-sdk/install.sh -q
- source /tmp/google-cloud-sdk/path.bash.inc
# Authenticating with the service account key file
- echo $GOOGLE_CLIENT_SECRET | base64 --decode --ignore-garbage > ./gcloud-api-key.json
- gcloud config set project $CLOUDSDK_CORE_PROJECT
- gcloud components install app-engine-java
- gcloud auth activate-service-account --key-file client-secret.json
- cd project1
- mvn clean install package
- 'mvn appengine:update'
CLOUDSDK_CORE_PROJECT : is a pipeline variable contains the project ID
GOOGLE_CLIENT_SECRET : is a pipeline variable contains the base64 encoded service account json file as explained in the attached link
and here is my app engine plugin in the pom.xml
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<enableJarClasses>false</enableJarClasses>
<oauth2>false</oauth2>
</configuration>
</plugin>
after I run my pipelines I got this error at executing the line of "mvn appengine:update"
lease visit https://developers.google.com/appengine/downloads for the latest SDK.
********************************************************
The following URL can be used to authenticate:
https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&client_id=550516889912.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/appengine.admin%20https://www.googleapis.com/auth/cloud-platform
Attempting to open it in your browser now.
Unable to open browser. Please open the URL above and copy the resulting code.
Please enter code: Encountered a problem: No line found
Please see the logs [/tmp/appcfg3177766291803906341.log] for further information.
and then the pipeline result is failed, I looked for this error for 2 days with no hope, I hope come one here help me out
Thanks in advance!
I fixed it, it turned out that the docs in bitbucket is misleading, here is the correct pipeline script, you just need to put this 3 lines of code to build and deploy to google cloud right after:
- mvn install package
- echo $GOOGLE_CLIENT_SECRET > /tmp/client-secret.json
- mvn appengine:update -Dappengine.additionalParams="--service_account_json_key_file=/tmp/client-secret.json"
$GOOGLE_CLIENT_SECRET is an environmental variable having the service account json of App Engine default service account or you can create a new one having project editor privileges
It helped me pass the authenticate error but now I see 403 in my logs. Surprisingly, the version is still getting pushed to app-engine but 0% traffic.
Beginning interaction for module default...
0% Created staging directory at: '/var/folders/ny/z92xw4ps0j71v43mnvjzjyd80000gn/T/appcfg16663468200304338426.tmp'
5% Scanning for jsp files.
8% Generated git repository information file.
20% Scanning files on local disk.
25% Initiating update.
28% Cloning 34 application files.
40% Uploading 3 files.
52% Uploaded 1 files.
61% Uploaded 2 files.
68% Uploaded 3 files.
73% Sending batch containing 3 file(s) totaling 41KB.
77% Initializing precompilation...
90% Deploying new version.
95% Closing update: new version is ready to start serving.
98% Uploading index definitions.
Feb. 19, 2018 1:21:24 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #0
Feb. 19, 2018 1:21:25 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #1
Feb. 19, 2018 1:21:25 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #2
Feb. 19, 2018 1:21:25 AM com.google.appengine.tools.admin.AbstractServerConnection send1
WARNING: Error posting to URL: https://appengine.google.com/api/datastore/index/add?app_id=clean-aleph-191303&version=beta-001&
403 Forbidden
You do not have permission to modify this app (app_id=u'f~clean-aleph-191303').
This is try #3
Error Details:
2018-02-19 01:20:57.438:INFO::main: Logging initialized #378ms
2018-02-19 01:20:57.575:INFO:oejs.Server:main: jetty-9.3.18.v20170406
2018-02-19 01:20:58.829:INFO:oeja.AnnotationConfiguration:main: Scanning elapsed time=711ms
2018-02-19 01:20:58.843:INFO:oejq.QuickStartDescriptorGenerator:main: Quickstart generating
2018-02-19 01:20:58.859:INFO:oejsh.ContextHandler:main: Started o.e.j.q.QuickStartWebApp#2aceadd4{/,file:///private/var/folders/ny/z92xw4ps0j71v43mnvjzjyd80000gn/T/appcfg16663468200304338426.tmp/,AVAILABLE}
2018-02-19 01:20:58.861:INFO:oejs.Server:main: Started #1808ms
2018-02-19 01:20:58.863:INFO:oejsh.ContextHandler:main: Stopped o.e.j.q.QuickStartWebApp#2aceadd4{/,file:///private/var/folders/ny/z92xw4ps0j71v43mnvjzjyd80000gn/T/appcfg16663468200304338426.tmp/,UNAVAILABLE}
Related
I have a Spring Boot app in Docker that runs on Heroku.
Recently, after updating Tomcat to 10.1.0-M10, I started getting this error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within
60 seconds of launch
The immediate thought of downgrading to lower versions doesn't work due to vulnerabilities in the earlier versions. I have checked possible causes and found Tomcat binding port issue.
I cannot set up fixed config for different ports as I am deploying to Heroku and dependent on their random ports.
My Dockerfile:
FROM azul/zulu-openjdk-alpine:11
ENV PORT=$PORT
COPY /target/app.jar /app.jar
CMD java -Xms256m -Xmx512m \
-Dlog4j2.formatMsgNoLookups=true \
-Djava.security.egd=file:/dev/./urandom \
-Dserver.port=$PORT \
-jar /app.jar
What is the way to solve it? Is there anything I am missing?
UPDATE:
There are more logs from Heroku:
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.057 [main] INFO c.g.s.z.ApplicationKt - Started ApplicationKt in 8.09 seconds (JVM running for 9.062)
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.060 [main] DEBUG o.s.b.a.ApplicationAvailabilityBean - Application availability state LivenessState changed to CORRECT
Feb 22 12:50:16 integration-test app/web.1 2022-02-22 20:50:16.063 [main] DEBUG o.s.b.a.ApplicationAvailabilityBean - Application availability state ReadinessState changed to ACCEPTING_TRAFFIC
Feb 22 12:51:06 integration-test heroku/web.1 Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I found a solution that wasn't perfect but seemed to work for me.
Downgraded Spring Boot from 2.6.3 to 2.6.1
Downgraded Tomcat from 10.X.X to 9.X.X
Removed dev tools dependencies
I think the two latest did the magic. Dev tools stopped asking for an extra port in the test/prod environment. Tomcat bound the port in the version 9.X.X but not in 10.X.X.
Even though I found the solution, I don't know why it behaved like this, and it isn't perfect security-wise.
from the error message it seems that $PORT is not resolved to any environment variable.
deploying to heroku you must use .env file to define env vars (you can't use docker run -e PORT=1234) see documentation
When you use heroku locally, you can set config vars in a .env file. When heroku local is run .env is read and each name/value pair is set in the environment. You can use this same .env file when using Docker: docker run -p 5000:5000 --env-file .env <image-name>
I am trying to deploy a spring boot microservices application to Google App Engine from Bitbucket Pipelines. I am getting this below error after commiting the code,
INFO: Setting up environment.
echo "${KEY_FILE}" | base64 -d >> /tmp/key-file.json
gcloud auth activate-service-account --key-file /tmp/key-file.json --quiet --verbosity=warning
Activated service account credentials for: [testproject-iamserviceaccoun#testproject.iam.gserviceaccount.com]
gcloud config set project testproject --quiet --verbosity=warning
Updated property [core/project].
> *INFO: Starting deployment to GCP app engine...*
gcloud app --quiet deploy 'app.yaml' --verbosity=warning
**ERROR: (gcloud.app.deploy) [/opt/atlassian/pipelines/agent/build/app.yaml] does not exist.
✖ Deployment failed.**
Please help me to solve this issue. Build Tool used is Maven.
bitbucket-pipelines.yml:
pipelines:
default:
- step:
name: Deploy to Google cloud
deployment: test
script:
- pipe: atlassian/google-app-engine-deploy:0.7.3
variables:
KEY_FILE: $KEY_FILE
PROJECT: 'testproject'
src/main/appengine/app.yaml:
runtime: java
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
You need to specify DEPLOYABLES in your bitbucket-pipelines.yml, pointing to the path of your app.yaml file.
pipelines:
default:
- step:
name: Deploy to Google cloud
deployment: test
script:
- pipe: atlassian/google-app-engine-deploy:0.7.3
variables:
KEY_FILE: $KEY_FILE
PROJECT: 'testproject'
DEPLOYABLES: src/main/appengine/app.yaml
Reference: https://bitbucket.org/atlassian/google-app-engine-deploy/src/master/
I'm developing a web application using Struts 2, Hibernate and etc and not using Maven. I put the needed jars in app.
I put my app in git (https://github.com/vahidhiv/vaphap) and want to use OpenShift to test it but I face this error.
What should I do?
The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 55966353e0b8cdebf9000040 -c "exec /usr/bin/runcon 'unconfined_u:system_r:openshift_t:s0:c2,c481' /bin/sh -c \"gear postreceive --init >> /tmp/initial-build.log 2>&1\""' returned an error. rc=255 .Last 10 kB of build output: The jbossews cartridge is already stopped Repairing links for 1 deployments Building git ref 'master', commit 6e5a635 Skipping Maven build due to absence of pom.xml Preparing build for deployment Deployment id is 3ec7fc2a Activating deployment Starting jbossews cartridge jbossews process failed to start ------------------------- Git Post-Receive Result: failure Activation status: failure Activation failed for the following gears: 55966353e0b8cdebf9000040 (Error activating gear: CLIENT_ERROR: Failed to execute: 'control start' for /var/lib/openshift/55966353e0b8cdebf9000040/jbossews # # ) Deployment completed with status: failure postreceive failed
I am trying to import a Grails project into STS. I'm running STS 3.6.1. I've also got the Groovy plugin installed, running compiler 1.8.6. Finally, I have Grails 2.1.4.
When I try to import a Grails project though (which is a Subversion repository), it is painfully slow, before it finally gives up:
The command 'C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe (4 Sep
2014 12:10:28)' was terminated because it didn't produce new output
for some time.
See details for the output produced so far.
If you think the command simply needed more time, you can increase the
time limit in the Grails preferences page.
See menu Windows >> Preferences >> Grails >> Launch Command:
C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe (4 Sep 2014 12:10:28)
---- System.out ---- | Loading Grails 2.1.4 | Configuring classpath | Downloading:
C:\Users\607534885\Software\grails-2.1.4\plugins\database-migration-1.3.2.pom
| Downloading:
C:\Users\607534885\Software\grails-2.1.4\lib\org.liquibase\liquibase-core\ivy-2.0.5.xml
| Downloading:
C:\Users\607534885\Software\grails-2.1.4\plugins\jquery-1.8.3.pom
---- System.err ----
Terminating process: Timeout: no new output for 180000 milliseconds
------System.out:----------- | Loading Grails 2.1.4 | Configuring classpath | Downloading:
C:\Users\607534885\Software\grails-2.1.4\plugins\database-migration-1.3.2.pom
| Downloading:
C:\Users\607534885\Software\grails-2.1.4\lib\org.liquibase\liquibase-core\ivy-2.0.5.xml
| Downloading:
C:\Users\607534885\Software\grails-2.1.4\plugins\jquery-1.8.3.pom
------System.err:-----------
Terminating process: Timeout: no new output for 180000 milliseconds
Why is Grails proving to be so slow? Or is this an issue with something else?
Figured it out. Rather pointless question in the end. We have an aggressive firewall in work and I simply needed to use a wifi connection instead as importing the project for the first time required third party software to be installed. Simples in the end.
After upgrading the appengine-maven-plugin from 1.7.5 to 1.7.6, trying to deploy my app now consistently fails with
$ mvn appengine:update
Beginning server interaction for myapp...
5% Using java7 runtime: false
25% Initiating update.
com.google.appengine.tools.admin.HttpIoException: Error posting to URL: https://appengine.google.com/api/appversion/create?app_id=myapp&version=1.7.6&
500 Internal Server Error
If I revert to 1.7.5 it works again, so it may be an issue with the 1.7.6 Maven plugin or SDK. I've tried both enabling and disabling java7 but it makes no difference.
Update: deploying with appcfg.sh works fine, so it must be something with the Maven plugin.
Update #2: running with mvn -X shows the following plugin dependencies:
[INFO] --- appengine-maven-plugin:1.7.6:update (default-cli) # myapp ---
[DEBUG] com.google.appengine:appengine-maven-plugin:jar:1.7.6:
...
[DEBUG] com.google.guava:guava:jar:14.0.1:compile
[DEBUG] com.google.appengine:appengine-tools-sdk:jar:1.7.6:compile