使用 API 键的 Jenkins CF 插件
Jenkins CF plugin using API key
是否可以让 CF plugin 使用 API 密钥而不是用户名和密码来登录并将应用程序推送到 IBM Cloud Platform?
这是我用来测试插件的非常简单的 Jenkinsfile
node('workers') {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
// properties(
// [
// pipelineTriggers([cron('0 16 * * * ')]),
// ]
// )
stage('checkout') {
checkout scm
}
stage('Build') {
if (isTimer()) {
echo "building by timer"
}
echo 'building'
}
stage('Test') {
echo 'Testing..'
}
stage('Deploy') {
pushToCloudFoundry(
target: 'https://api.ng.bluemix.net',
organization: 'WXS',
cloudSpace: 'dev',
credentialsId: 'cfplugin-henry-test'
)
}
}
credentialsId cfplugin-henry-test
是 Jenkins 上的秘密文本,其中包含我的 API 密钥。但是,Jenkins 构建返回 ERROR: No credentials have been given.
难道插件没有API键登录的功能?
您可以创建一个脚本来下载 IBM Cloud CLI 并执行您需要的 cf 推送:
#!/bin/bash
set -e
echo "Installing the IBM Cloud API v.0.6.6"
wget https://public.dhe.ibm.com/cloud/bluemix/cli/bluemix-cli/0.6.6/IBM_Cloud_CLI_0.6.6_amd64.tar.gz
tar -xvf IBM_Cloud_CLI_0.6.6_amd64.tar.gz
./Bluemix_CLI/install_bluemix_cli
# Ignore updates because they need confirmation from the user
bx config --check-version=false
bx api https://api.ng.bluemix.net
bx login
bx target -o wxs -s dev
bx cf push
确保您有 BLUEMIX_API_KEY
的值,bx login
将使用该值。
我从我在 Travis 中使用的 bx-blue-green
npm 模块改编了脚本。
是否可以让 CF plugin 使用 API 密钥而不是用户名和密码来登录并将应用程序推送到 IBM Cloud Platform?
这是我用来测试插件的非常简单的 Jenkinsfile
node('workers') {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
// properties(
// [
// pipelineTriggers([cron('0 16 * * * ')]),
// ]
// )
stage('checkout') {
checkout scm
}
stage('Build') {
if (isTimer()) {
echo "building by timer"
}
echo 'building'
}
stage('Test') {
echo 'Testing..'
}
stage('Deploy') {
pushToCloudFoundry(
target: 'https://api.ng.bluemix.net',
organization: 'WXS',
cloudSpace: 'dev',
credentialsId: 'cfplugin-henry-test'
)
}
}
credentialsId cfplugin-henry-test
是 Jenkins 上的秘密文本,其中包含我的 API 密钥。但是,Jenkins 构建返回 ERROR: No credentials have been given.
难道插件没有API键登录的功能?
您可以创建一个脚本来下载 IBM Cloud CLI 并执行您需要的 cf 推送:
#!/bin/bash
set -e
echo "Installing the IBM Cloud API v.0.6.6"
wget https://public.dhe.ibm.com/cloud/bluemix/cli/bluemix-cli/0.6.6/IBM_Cloud_CLI_0.6.6_amd64.tar.gz
tar -xvf IBM_Cloud_CLI_0.6.6_amd64.tar.gz
./Bluemix_CLI/install_bluemix_cli
# Ignore updates because they need confirmation from the user
bx config --check-version=false
bx api https://api.ng.bluemix.net
bx login
bx target -o wxs -s dev
bx cf push
确保您有 BLUEMIX_API_KEY
的值,bx login
将使用该值。
我从我在 Travis 中使用的 bx-blue-green
npm 模块改编了脚本。