While deploying to GCP using Terraform and in our YAML file we have the following section
# Deploy to Cloud Run
- id: 'deploy'
name: 'gcr.io/cloud-builders/gcloud'
waitFor: ['build-image','push-image']
entrypoint: bash
args:
- '-c'
- |
gcloud beta run services update $_SERVICE_NAME \
'--platform=$_PLATFORM' \
'--image=$_IMAGE_NAME' \
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID \
'--region=$_GCP_REGION' \
--tag '$_REVISION' \
We set WaitFor for all previous dependencies for testing. We are getting this error:
Starting Step #3 - "deploy"
Step #3 - "deploy": Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #3 - "deploy": Deploying...
Step #3 - "deploy": Creating Revision......interrupted
Step #3 - "deploy": Deployment failed
Step #3 - "deploy": ERROR: (gcloud.beta.run.services.update) Revision my-service-ui-00007-doq is not ready.
Finished Step #3 - "deploy"
ERROR
ERROR: build step 3 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1
We have tried playing around with the command line and that is showing the same error. We tried several times, so this is not a random error.
Any idea what could cause this? Or any clue how we could investigate it?
I've experienced that if a non-ready revision has a traffic tag assigned (as can be the case when tagging the revision during e.g. deploy), subsequent deploys might fail. So best to go through the UI and remove all traffic tags from revisions which are not green. Maybe that fixes the problem. Just a guess if this could be the problem.
Christian
Remove that revision and tag from the YAML file and try again.
Removing from YAML will help because when updating traffic, "0%" traffic was being assigned to every revision specified in the traffic field. Since this revision is not ready, any operation that is assigning traffic (even though 0%) is causing this error.
Related
I've encountered an issue trying to use bazel as a build tool for remix. I've been able to run remix in dev mode but currently unable to get remix build to work.
I've encountered a few errors that led up to this point. I'll list the errors in the order which they occurred with my fixes (just incase any of the fixes introduces a new issue)
First error in the bazel sandbox is related to a transitive dependency of #remix-run/dev (#remix-run/dev->gunzip-maybe->browserify-zlib). Bazel failed to fetch the bazel repository #npm__browserify-zlib__0.1.4. I assumed this was a bazel issue and tried to override browserify-zlib#0.1.4 with browserify-zlib#0.2.0, which worked. Here is bazel error for reference:
ERROR: /Users/emmanuel/projects/bbbazel/WORKSPACE:89:17: fetching _npm_import rule //external:npm__browserify-zlib__0.1.4: Traceback (most recent call last):
File "/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/external/aspect_rules_js/npm/private/npm_import.bzl", line 471, column 27, in _impl
pkg_json = json.decode(rctx.read(pkg_json_path))
Error in decode: at offset 685, object has duplicate key: "main"
ERROR: /private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/external/npm/BUILD.bazel:3012:6: #npm//:npm__browserify-zlib__0.1.4_source_directory depends on #npm__browserify-zlib__0.1.4//:source_directory in repository #npm__browserify-zlib__0.1.4 which failed to fetch. no such package '#npm__browserify-zlib__0.1.4//': at offset 685, object has duplicate key: "main"
Next error in the bazel sandbox is related to another transitive dependency of #remix-run/dev (#remix-run/dev->xdm->deasync). The install lifecycle hook for the deasync npm package makes a call to the node-gyp binary which doesn't exist in the sandbox and the bazel build command fails during setup. To fix this, I disabled the install lifecycle hook (I also disabled it with a pnpm install outside the sandbox and the remix build command executed perfectly) which led to the final error. Here's the error message for this error:
/Users/emmanuel/projects/bbbazel/BUILD.bazel:5:22: Running lifecycle hooks on npm package deasync#0.1.28 failed: (Exit 1): lifecycle-hooks.sh failed: error executing command (from target //:.aspect_rules_js/node_modules/deasync#0.1.28/lc) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh deasync ../../../external/npm__deasync__0.1.28/package ... (remaining 1 argument skipped)
/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/node-gyp-bin/node-gyp: line 5: 1211: command not found
node-gyp not found! Please upgrade your install of npm! You need at least 1.1.5 (I think) and preferably 1.1.30.
> deasync#0.1.28 install /private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/deasync#0.1.28/node_modules/deasync
> node ./build.js
===============================================================
Failure while running lifecycle hook for package 'deasync#0.1.28':
Script: 'install'
Command: `node ./build.js`
Stack trace:
spawn ENOENT
at ChildProcess.<anonymous> (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:91930)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1100:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
The final error suggests a bug with remix, but since it only occurs in the bazel sandbox I think it may be an issue that cuts across bazel and remix. The error returned is shown below:
The following error is a bug in Remix; please open an issue! https://github.com/remix-run/remix/issues/new
Missing output for entry point
Error
at Object.onCompileFailure (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/cli/commands.js:180:13)
at Object.compile (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/compiler/remixCompiler.js:34:134)
at async Object.build (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/compiler/build.js:33:3)
at async Object.build (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/cli/commands.js:175:3)
at async Object.run (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/cli/run.js:449:7)
Building Remix app in production mode...
Target //examples/remix:build failed to build
I've tried to run it outside bazel and with pnpm (I added the override to the package.json for browserify-zlip#0.2.0, then I ran pnpm instal with --ignore-scripts flag) and it builds fine.
I'm not sure if this is a bug with remix or a bazel issue. Has anyone else experienced this? Or does anyone having a working version of remix with bazel as the build tool?
I've created a minified version of the repository in the state of the 3rd error https://github.com/noelenwenede/bbbazel. Start up instructions are in the readme file.
Classic case of it works on my machine. I am building two react-native apps. App A and App B. Both of the applications were bootstrapped using expo.
When I run the command to build either app locally expo build:ios they both build. Yet when I attempt to build the applications in gitlab-ci only application B fails to build with the following message:
[23:07:28] warn Package babel-preset-expo has been ignored because it contains invalid configuration. Reason: Cannot find module 'babel-preset-expo/package.json'
[23:07:28] Require stack:
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/tools/config/resolveNodeModuleDir.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/tools/releaseChecker/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/runServer.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/commands/server/server.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/commands/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/node_modules/#react-native-community/cli/build/index.js
[23:07:28] - /builds/XXX/application-b/node_modules/react-native/local-cli/cli.js
[23:07:28]
[23:07:29] Starting Metro Bundler on port 19001.
[23:07:29] debug Watch mode is not supported in this environment
[23:07:29] debug Checking for a newer version of React Native
[23:07:29] debug Current version: 0.61.4
[23:07:29] debug No release cache found
[23:07:29] debug No release cache found
[23:07:29] debug Checking for newer releases on GitHub
[23:07:29] debug No release cache found
[23:07:30] Publishing to channel 'default'...
[23:07:30] debug Saving "6d6386b01438c6ef0acd213d304b5839" to cache
[23:07:30] debug No release cache found
[23:07:30] debug No release cache found
[23:07:30] debug Latest release: 0.60.0
[23:07:32] Building iOS bundle
[23:07:43] node_modules/expo/AppEntry.js: Cannot find module 'babel-preset-expo' from '/builds/XXX/application-b'
[23:07:43] › Closing Expo server
[23:07:43] node_modules/expo/AppEntry.js: Cannot find module 'babel-preset-expo' from '/builds/XXX/application-b'
[23:07:43] Failed building JavaScript bundle.
[23:07:43] ::ffff:127.0.0.1 - - [06/Apr/2020:23:07:43 +0000] "GET /node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios HTTP/1.1" 500 - "-" "axios/0.19.0"
[23:07:43] › Stopping Metro bundler
[23:07:43] Packager URL http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?dev=false&minify=true&hot=false&platform=ios returned unexpected code 500. Please open your project in the Expo app and see if there are any errors. Also scroll up and make sure there were no errors or warnings when opening your project.
I have tried having the CI explicitly install the module babel-preset-expo, but that does not fix the issue. My babel.config.js is identical for both apps and looks like this:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
};
};
I have the following lines in my both of my package.json:
"devDependencies": {
"#babel/core": "^7.0.0",
"babel-preset-expo": "^8.0.0"
},
The file in both applications being referenced in the error AppEntry.js is identical as well.
Here is my gitlab-ci.yml:
image: node/alpine
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- ~/.npm
stages:
- deploy
- tag
before_script:
- echo $CI_BUILD_REF
- echo $CI_PROJECT_DIR
- apk add --no-cache bash build-base gcc git python3 curl
- PATCH=`git log --pretty=oneline | wc -l | sed -e 's/^[[:space:]]*//'`
- VERSION=`cat VERSION`
- VERSION=${VERSION%?}
- TAG="${VERSION}${PATCH}"
- echo "Build version = ${TAG}"
expo-build:
stage: deploy
artifacts:
paths:
- ipas/
script:
- sed -i "s/0.0.0/${TAG}/g" app.json
- npm ci --production --cache .npm --prefer-offline
- npx expo login -u $EXPO_USERNAME -p $EXPO_PASSWORD
- EXPO_DEBUG=true npx expo build:ios --non-interactive # This works because it has been already built once through the cli, credentials cannot be pass into env
- mkdir -p ipas
- curl "$(npx expo url:ipa --non-interactive)" -o ipas/bravo-teller-$TAG.ipa
only:
- master
Any feedback or suggestions as to what this could be would be greatly appreciated. Thanks
Actually, the babel-preset-expo is not a devDependencies you should add it to dependencies furthermore likely you should use lazy load by using the following code on your babel configuration:
[
'babel-preset-expo',
{
lazyImports: true,
},
]
Allure results are generated (xmls) and can be viewed by running allure serve outside the allure-results directory but when configured in Jenkins using the allure results directory with relative path from Jenkins workspace, the allure results are not found. Presumably there is something wrong with the path
[allure_test] $ /Users/me/.jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/Allure_2.7.0/bin/allure generate -c -o /Users/me/.jenkins/workspace/allure_test/allure-report
allure-results does not exists
Report successfully generated to /Users/me/.jenkins/workspace/allure_test/allure-report
Allure report was successfully generated.
Relative Path defined for allure report is
../../repos/partner-portal/target/allure-results
The report is generated but with no results
Here is the solution:
1. Inside your work space (For me it is D:\m\Automation Project\Tests), Create a folder named "target" containing two subfolders "allure-results" and "allure-reports".
In Post Build Actions of Jenkins Project provide these entries.
Results: target/allure-results
Report Path: target/allure-reports
Now run your tests and allure reports will be generated without any issues.
I struggled for over 24 hours and could not sleep whole night just because of this issue. There were no clear instructions related to this and how it works. Finally, I figured it out.
May be its little too late for this answer but could you please create the "allure-results" folder in your workspace (like /Users/me/.jenkins/workspace/allure_test/allure-results)?
After I configure Allure report in jenkins, and using behave command, I finally see following output and saw the working report in my jenkins build plan:
.
.
.
.
D:\PythonProject\PythonBehave>behave -f allure_behave.formatter:AllureFormatter -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-results D:\PythonProject\PythonBehave\features
Failing scenarios:
features/example.feature:17 user can search text in google -- #2.2 Incorrect
features/github_login.feature:13 User attempt to login with wrong username and password -- #1.1 InCorrect
features/github_login.feature:14 User attempt to login with wrong username and password -- #1.2 InCorrect
features/github_login.feature:18 User attempt to login with correct username and password
0 features passed, 2 failed, 0 skipped
3 scenarios passed, 4 failed, 0 skipped
12 steps passed, 4 failed, 8 skipped, 0 undefined
Took 3m24.651s
D:\PythonProject\PythonBehave>exit 1
Build step 'Custom Python Builder' marked build as failure
[PythonAllure] $ C:\Users\Alex\.jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\Allure_2.13.1\bin\allure.bat generate C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-results -c -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
Report successfully generated to C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
Finished: FAILURE
And before I used to get this output when there was no allure-results folder in my workspace:
[PythonAllure] $ C:\Users\Alex\.jenkins\tools\ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation\Allure_2.13.1\bin\allure.bat generate -c -o C:\Users\Alex\.jenkins\workspace\PythonAllure\allure-report
we are not using any post-build steps on UI but using jenkins pipeline groovy script as below:
def allureReportsGenerationTask() {
try {
allure([includeProperties: false, jdk: '', properties: [], reportBuildPolicy: 'ALWAYS', results: [[path: 'target/allure-results']]])
} catch(Exception error) {
println("Caught Exception: ${error}")
}
}
The project structure was like that only
ProjectRepo
- src
- target
-alure-results
- pom.xml
- testng.xml
In this case, we are getting the allure-results getting generated but it was not getting picked in the Jenkins pipeline allure plugin. ON UI below command was running always
/opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
you can see Jenkins was not able to find allure-results for generating parameters in the above Jenkins pipeline command
We added the below parameter in pom.xml maven-surefire-plugin
<systemPropertyVariables>
<allure.results.directory>../target/allure-results</allure.results.directory>
</systemPropertyVariables>
Now project structure becomes
-ProjectRepo
- src
- pom.xml
- testng.xml
target
-allure-results
Now on running the same via pipeline script, we were able to run the below command
/opt/jenkins/tools/ru.yandex.qatools.allure.jenkins.tools.AllureCommandlineInstallation/allure/bin/allure generate /opt/jenkins/workspace/ProjectRepoPipeline/target/allure-results -c -o /opt/jenkins/workspace/ProjectRepoPipeline/allure-report
ProjectRepoPipeline - This is the Jenkins pipeline name that is running CI/CD
I am trying to use Ansible Container for a basic example which is supposed to install Node within the image. When I use the ansible-container build command, after successfully building the conductor image, it fails the first task with a sudo related error. The task in question requires root privileges to be executed.
I am running Debian GNU/Linux 9.2 (stretch) with Docker 17.09.0-ce installed through the Docker APT repository. I tried with Ansible both from Debian Stretch (2.2.1.0-2) and from Pypi (2.4.1.0). I tried Ansible Container from Pypi (0.9.3rc0) and from the latest Git source. I always get the exact same error output.
The Ansible module complains about the following:
sudo: error while loading shared libraries: libsudo_util.so.0: cannot open shared object file: No such file or directory
The task being run looks like the following:
- name: Add the Node Source repository signing certificate to APT
apt_key:
id: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280
keyserver: hkps://hkps.pool.sks-keyservers.net
become: yes
Both the conductor as well as the service I try to create use the debian:stretch base image.
I am running the ansible-container build command with sudo prepended, because only root may access the Docker socket on my system.
Here is the content of my container.yml:
version: "2"
settings:
conductor:
base: debian:stretch
project_name: container_test
services:
nodejs:
from: debian:stretch
roles:
- nodejs
registries: {}
Here is the full error output:
Building Docker Engine context...
Starting Docker build of Ansible Container Conductor image (please be patient)...
Parsing conductor CLI args.
Docker™ daemon integration engine loaded. Build starting. project=container_test
Building service... project=container_test service=nodejs
PLAY [nodejs] ******************************************************************
TASK [Gathering Facts] *********************************************************
ok: [nodejs]
TASK [nodejs : Add the Node Source repository signing certificate to APT] ******
fatal: [nodejs]: FAILED! => {"changed": false, "module_stderr": "sudo: error while loading shared libraries: libsudo_util.so.0: cannot open shared object file: No such file or directory\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 127}
to retry, use: --limit #/tmp/tmpTRBQDe/playbook.retry
PLAY RECAP *********************************************************************
nodejs : ok=1 changed=0 unreachable=0 failed=1
ERROR Error applying role! engine=<container.docker.engine.Engine object at 0x7f84da0c5ed0> exit_code=2 playbook=[{'hosts': u'nodejs', 'roles': ['nodejs'], 'vars': {}}]
Traceback (most recent call last):
File "/usr/local/bin/conductor", line 11, in <module>
load_entry_point('ansible-container', 'console_scripts', 'conductor')()
File "/_ansible/container/__init__.py", line 19, in __wrapped__
return fn(*args, **kwargs)
File "/_ansible/container/cli.py", line 408, in conductor_commandline
**params)
File "/_ansible/container/__init__.py", line 19, in __wrapped__
return fn(*args, **kwargs)
File "/_ansible/container/core.py", line 843, in conductorcmd_build
raise RuntimeError('Build failed.')
RuntimeError: Build failed.
Conductor terminated. Cleaning up. command_rc=1 conductor_id=e8899239ad1017a89acc97396d38ab805d937a7b3d74e5a7d2741d7b1124bb0c save_container=False
ERROR Conductor exited with status 1
I found the cause for this:
The base image debian:stretch does not include sudo. Therefore a solution was to set the become_method to su instead. Normally, this can either be done per task, host or playbook. Because it is not obvious where the equivalent of a playbook lies in Ansible Container and how the concept of hosts applies, I only really had the option to use the task level.
I decided to add a role which installs sudo in the image and only set the become_method to su for the solitary task within this role. Atfer the role is applied, no further change is needed and the original tasks work.
A follow-up problem then was, that also GnuPG was not installed either to accomplish the apt_key module task properly. The following solution solves both problems:
- become: yes
become_method: su
block:
- name: Update package cache
apt:
update_cache: yes
cache_valid_time: 86400
- name: Install GnuPG
package:
name: gnupg2
state: present
- name: Install sudo
package:
name: sudo
state: present
Supposedly a more clean option would be to generate a base image that already includes these dependencies to allow for a more streamlined Ansible Container image generation.
My Jenkins job set for an IOS Project clones (fetches) the code from Bitbucket but fails to run one of the last scripts for building the Xcode project.
The script is called.I get the following error it really does not mean a lot for me.
Has anyone had a similar problem.I am pretty sure that there is something wrong with the project settings since other jobs in the jenkins run perfect.
PhaseScriptExecution Run\ Script
/Users/jenkins/Library/Developer/Xcode/DerivedData/myApp-Workspace-doqiapyymubizteljhyzayqxdtyk/Build/Intermediates/Target.build/Release-iphoneos/Target.build/Script-334A8A5117785D7D001DC5DA.sh
cd "/Users/Shared/Jenkins/Home/workspace/myApp - BETA"
/bin/sh -c /Users/jenkins/Library/Developer/Xcode/DerivedData/myDriveriOSDriver-Workspace- doqiapyymubizteljhyzayqxdtyk/Build/Intermediates/Driver.build/Release-iphoneos/Driver.build/Script-334A8A5117785D7D001DC5DA.sh
fatal: Not a git repository: '/Users/Shared/Jenkins/Home/workspace/myApp - BETA/../.git'
VERSION: 2.1.3.0
2014-01-24 13:54:29.529 defaults[61460:507] Unexpected argument Driver; leaving defaults unchanged.
Command /bin/sh failed with exit code 1
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/jenkins/Library/Developer/Xcode/DerivedData/myApp- Workspace-doqiapyymubizteljhyzayqxdtyk/Build/Intermediates/Target.build/Release-iphoneos/Target.build/Script-334A8A5117785D7D001DC5DA.sh
(1 failure)
The mentioned script sets some environment variables before the fatal error including;
...
setenv YACC yacc
setenv arch armv7s
setenv variant normal
There is a clear error in the log:
fatal: Not a git repository: '/Users/Shared/Jenkins/Home/workspace/myApp - BETA/../.git'
By analyzing your error log I guess that problem is in following statement
cd "/Users/Shared/Jenkins/Home/workspace/myApp - BETA"
instead try
cd "/Users/Shared/Jenkins/Home/workspace/myApp\ -\ BETA"
hope it helps