是否可以让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'
)
}
}
凭据ID cfplugin-henry-test
是Jenkins上具有我的API密钥的秘密文本。但是,Jenkins版本会返回ERROR: No credentials have been given.
那么插件不具有使用API密钥登录的功能吗?
答案 0 :(得分:1)
您可以创建一个脚本来下载IBM Cloud CLI并执行所需的cf push:
#!/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模块中的脚本。